2015-11-19 01:32:29 +08:00
|
|
|
import ko from 'ko';
|
2021-01-25 05:58:06 +08:00
|
|
|
import { KeyState } from 'Common/Enums';
|
|
|
|
import { Focused } from 'Common/EnumsUser';
|
2021-03-10 18:44:48 +08:00
|
|
|
import { keyScope, leftPanelDisabled, Settings, SettingsGet } from 'Common/Globals';
|
2021-02-17 03:12:23 +08:00
|
|
|
import { ThemeStore } from 'Stores/Theme';
|
2020-09-04 18:05:17 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
export const AppUserStore = {
|
|
|
|
attachmentsActions: ko.observableArray(),
|
2015-11-19 01:32:29 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
devEmail: '',
|
|
|
|
devPassword: '',
|
2020-10-27 18:09:24 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
populate: () => {
|
|
|
|
AppUserStore.projectHash(SettingsGet('ProjectHash'));
|
2020-10-27 18:09:24 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
AppUserStore.contactsAutosave(!!SettingsGet('ContactsAutosave'));
|
|
|
|
AppUserStore.useLocalProxyForExternalImages(!!SettingsGet('UseLocalProxyForExternalImages'));
|
2020-10-27 18:09:24 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
AppUserStore.contactsIsAllowed(!!SettingsGet('ContactsIsAllowed'));
|
2015-11-19 01:32:29 +08:00
|
|
|
|
2020-09-04 18:05:17 +08:00
|
|
|
const attachmentsActions = Settings.app('attachmentsActions');
|
2021-03-11 05:41:35 +08:00
|
|
|
AppUserStore.attachmentsActions(Array.isNotEmpty(attachmentsActions) ? attachmentsActions : []);
|
2015-11-19 01:32:29 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
AppUserStore.devEmail = SettingsGet('DevEmail');
|
|
|
|
AppUserStore.devPassword = SettingsGet('DevPassword');
|
2016-04-21 01:12:51 +08:00
|
|
|
}
|
2021-03-11 05:41:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
ko.addObservablesTo(AppUserStore, {
|
|
|
|
currentAudio: '',
|
|
|
|
|
|
|
|
focusedState: Focused.None,
|
|
|
|
|
|
|
|
projectHash: '',
|
|
|
|
threadsAllowed: false,
|
|
|
|
|
|
|
|
composeInEdit: false,
|
|
|
|
|
|
|
|
contactsAutosave: false,
|
|
|
|
useLocalProxyForExternalImages: false,
|
|
|
|
|
|
|
|
contactsIsAllowed: false
|
|
|
|
});
|
|
|
|
|
|
|
|
AppUserStore.focusedState.subscribe(value => {
|
|
|
|
switch (value) {
|
|
|
|
case Focused.MessageList:
|
|
|
|
keyScope(KeyState.MessageList);
|
|
|
|
ThemeStore.isMobile() && leftPanelDisabled(true);
|
|
|
|
break;
|
|
|
|
case Focused.MessageView:
|
|
|
|
keyScope(KeyState.MessageView);
|
|
|
|
ThemeStore.isMobile() && leftPanelDisabled(true);
|
|
|
|
break;
|
|
|
|
case Focused.FolderList:
|
|
|
|
keyScope(KeyState.FolderList);
|
|
|
|
ThemeStore.isMobile() && leftPanelDisabled(false);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|