snappymail/dev/Stores/User/App.js

80 lines
1.9 KiB
JavaScript
Raw Normal View History

2015-11-19 01:32:29 +08:00
import ko from 'ko';
2019-07-05 03:19:24 +08:00
import { Focused, KeyState } from 'Common/Enums';
2017-02-09 01:48:53 +08:00
2019-07-05 03:19:24 +08:00
import { keyScope, leftPanelDisabled } from 'Common/Globals';
2015-11-19 01:32:29 +08:00
2019-07-05 03:19:24 +08:00
import { AbstractAppStore } from 'Stores/AbstractApp';
2015-11-19 01:32:29 +08:00
const Settings = rl.settings;
2019-07-05 03:19:24 +08:00
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);
const isMobile = Settings.app('mobile');
2017-02-09 01:48:53 +08:00
this.focusedState.subscribe((value) => {
2019-07-05 03:19:24 +08:00
switch (value) {
2015-11-19 01:32:29 +08:00
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.get('ProjectHash'));
2015-11-19 01:32:29 +08:00
this.contactsAutosave(!!Settings.get('ContactsAutosave'));
this.useLocalProxyForExternalImages(!!Settings.get('UseLocalProxyForExternalImages'));
2015-11-19 01:32:29 +08:00
this.contactsIsAllowed(!!Settings.get('ContactsIsAllowed'));
2015-11-19 01:32:29 +08:00
const attachmentsActions = Settings.app('attachmentsActions');
2020-09-04 23:07:35 +08:00
this.attachmentsActions(Array.isNotEmpty(attachmentsActions) ? attachmentsActions : []);
2015-11-19 01:32:29 +08:00
this.devEmail = Settings.get('DevEmail');
this.devPassword = Settings.get('DevPassword');
2016-04-21 01:12:51 +08:00
}
2015-11-19 01:32:29 +08:00
}
export default new AppUserStore();