snappymail/dev/Stores/User/App.js

85 lines
2 KiB
JavaScript
Raw Normal View History

2015-11-19 01:32:29 +08:00
import ko from 'ko';
import {Focused, KeyState} from 'Common/Enums';
2017-02-09 01:48:53 +08:00
import {keyScope, leftPanelDisabled} from 'Common/Globals';
2016-06-07 05:57:52 +08:00
import {isNonEmptyArray} from 'Common/Utils';
2015-11-19 01:32:29 +08:00
2016-08-24 06:17:50 +08:00
import * as Settings from 'Storage/Settings';
2015-11-19 01:32:29 +08:00
import {AbstractAppStore} from 'Stores/AbstractApp';
class AppUserStore extends AbstractAppStore
{
2016-07-16 05:29:42 +08:00
constructor() {
2015-11-19 01:32:29 +08:00
super();
this.currentAudio = ko.observable('');
this.focusedState = ko.observable(Focused.None);
2017-02-09 01:48:53 +08:00
const isMobile = Settings.appSettingsGet('mobile');
this.focusedState.subscribe((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);
2017-02-09 01:48:53 +08:00
if (isMobile) {
leftPanelDisabled(true);
}
2015-11-19 01:32:29 +08:00
break;
case Focused.MessageView:
2016-06-07 05:57:52 +08:00
keyScope(KeyState.MessageView);
2017-02-09 01:48:53 +08:00
if (isMobile) {
leftPanelDisabled(true);
}
2015-11-19 01:32:29 +08:00
break;
case Focused.FolderList:
2016-06-07 05:57:52 +08:00
keyScope(KeyState.FolderList);
2017-02-09 01:48:53 +08:00
if (isMobile) {
leftPanelDisabled(false);
}
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
}
});
2015-11-19 01:32:29 +08:00
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
}
export default new AppUserStore();