snappymail/dev/Stores/User/App.jsx

75 lines
1.8 KiB
React
Raw Normal View History

2015-11-19 01:32:29 +08:00
import ko from 'ko';
import {Focused, KeyState} from 'Common/Enums';
2016-06-07 05:57:52 +08:00
import {keyScope} from 'Common/Globals';
2016-06-16 07:36:44 +08:00
import * as Settings from 'Storage/Settings';
2016-06-07 05:57:52 +08:00
import {isNonEmptyArray} from 'Common/Utils';
2015-11-19 01:32:29 +08:00
import {AbstractAppStore} from 'Stores/AbstractApp';
class AppUserStore extends AbstractAppStore
{
constructor()
{
super();
this.currentAudio = ko.observable('');
this.focusedState = ko.observable(Focused.None);
2016-06-30 08:02:45 +08:00
this.focusedState.subscribe(function(value) {
2015-11-19 01:32:29 +08:00
switch (value)
{
case Focused.MessageList:
2016-06-07 05:57:52 +08:00
keyScope(KeyState.MessageList);
2015-11-19 01:32:29 +08:00
break;
case Focused.MessageView:
2016-06-07 05:57:52 +08:00
keyScope(KeyState.MessageView);
2015-11-19 01:32:29 +08:00
break;
case Focused.FolderList:
2016-06-07 05:57:52 +08:00
keyScope(KeyState.FolderList);
2015-11-19 01:32:29 +08:00
break;
2016-06-30 08:02:45 +08:00
default:
break;
2015-11-19 01:32:29 +08:00
}
}, this);
this.projectHash = ko.observable('');
this.threadsAllowed = ko.observable(false);
this.composeInEdit = ko.observable(false);
this.contactsAutosave = ko.observable(false);
this.useLocalProxyForExternalImages = ko.observable(false);
this.contactsIsAllowed = ko.observable(false);
this.attachmentsActions = ko.observableArray([]);
this.devEmail = '';
this.devPassword = '';
}
populate() {
super.populate();
this.projectHash(Settings.settingsGet('ProjectHash'));
this.contactsAutosave(!!Settings.settingsGet('ContactsAutosave'));
this.useLocalProxyForExternalImages(!!Settings.settingsGet('UseLocalProxyForExternalImages'));
this.contactsIsAllowed(!!Settings.settingsGet('ContactsIsAllowed'));
2016-04-30 07:42:18 +08:00
const attachmentsActions = Settings.appSettingsGet('attachmentsActions');
2016-06-07 05:57:52 +08:00
this.attachmentsActions(isNonEmptyArray(attachmentsActions) ? attachmentsActions : []);
2015-11-19 01:32:29 +08:00
this.devEmail = Settings.settingsGet('DevEmail');
this.devPassword = Settings.settingsGet('DevPassword');
2016-04-21 01:12:51 +08:00
}
2015-11-19 01:32:29 +08:00
}
module.exports = new AppUserStore();