snappymail/dev/Stores/User/App.js
djmaze 6a454ec624 Convert user stores to single object instances
Removed unused ContactUserStore.exportingCsv and ContactUserStore.exportingVcf
2021-03-10 22:41:35 +01:00

62 lines
1.6 KiB
JavaScript

import ko from 'ko';
import { KeyState } from 'Common/Enums';
import { Focused } from 'Common/EnumsUser';
import { keyScope, leftPanelDisabled, Settings, SettingsGet } from 'Common/Globals';
import { ThemeStore } from 'Stores/Theme';
export const AppUserStore = {
attachmentsActions: ko.observableArray(),
devEmail: '',
devPassword: '',
populate: () => {
AppUserStore.projectHash(SettingsGet('ProjectHash'));
AppUserStore.contactsAutosave(!!SettingsGet('ContactsAutosave'));
AppUserStore.useLocalProxyForExternalImages(!!SettingsGet('UseLocalProxyForExternalImages'));
AppUserStore.contactsIsAllowed(!!SettingsGet('ContactsIsAllowed'));
const attachmentsActions = Settings.app('attachmentsActions');
AppUserStore.attachmentsActions(Array.isNotEmpty(attachmentsActions) ? attachmentsActions : []);
AppUserStore.devEmail = SettingsGet('DevEmail');
AppUserStore.devPassword = SettingsGet('DevPassword');
}
};
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;
}
});