diff --git a/dev/App/User.js b/dev/App/User.js index c9dd5f98e..0b6af9305 100644 --- a/dev/App/User.js +++ b/dev/App/User.js @@ -48,17 +48,17 @@ import { import { getNotification, i18n } from 'Common/Translator'; -import AppStore from 'Stores/User/App'; -import SettingsStore from 'Stores/User/Settings'; -import NotificationStore from 'Stores/User/Notification'; -import AccountStore from 'Stores/User/Account'; -import ContactStore from 'Stores/User/Contact'; +import { AppUserStore } from 'Stores/User/App'; +import { SettingsUserStore } from 'Stores/User/Settings'; +import { NotificationUserStore } from 'Stores/User/Notification'; +import { AccountUserStore } from 'Stores/User/Account'; +import { ContactUserStore } from 'Stores/User/Contact'; import { IdentityUserStore } from 'Stores/User/Identity'; -import TemplateStore from 'Stores/User/Template'; -import FolderStore from 'Stores/User/Folder'; -import PgpStore from 'Stores/User/Pgp'; -import MessageStore from 'Stores/User/Message'; -import QuotaStore from 'Stores/User/Quota'; +import { TemplateUserStore } from 'Stores/User/Template'; +import { FolderUserStore } from 'Stores/User/Folder'; +import { PgpUserStore } from 'Stores/User/Pgp'; +import { MessageUserStore } from 'Stores/User/Message'; +import { QuotaUserStore } from 'Stores/User/Quota'; import { ThemeStore } from 'Stores/Theme'; import * as Local from 'Storage/Client'; @@ -131,7 +131,7 @@ class AppUser extends AbstractApp { ['keydown','keyup'].forEach(t => doc.addEventListener(t, fn)); ['touchstart','mousedown','mousemove','keydown'].forEach( - t => doc.addEventListener(t, SettingsStore.delayLogout, {passive:true}) + t => doc.addEventListener(t, SettingsUserStore.delayLogout, {passive:true}) ); shortcuts.add('escape,enter', '', KeyState.All, () => rl.Dropdowns.detectVisibility()); @@ -146,10 +146,10 @@ class AppUser extends AbstractApp { } reloadFlagsCurrentMessageListAndMessageFromCache() { - MessageStore.messageList.forEach(message => + MessageUserStore.messageList.forEach(message => MessageFlagsCache.initMessage(message) ); - MessageFlagsCache.initMessage(MessageStore.message()); + MessageFlagsCache.initMessage(MessageUserStore.message()); } /** @@ -157,58 +157,58 @@ class AppUser extends AbstractApp { * @param {boolean=} bDropCurrenFolderCache = false */ reloadMessageList(bDropPagePosition = false, bDropCurrenFolderCache = false) { - let iOffset = (MessageStore.messageListPage() - 1) * SettingsStore.messagesPerPage(); + let iOffset = (MessageUserStore.messageListPage() - 1) * SettingsUserStore.messagesPerPage(); if (bDropCurrenFolderCache) { - setFolderHash(FolderStore.currentFolderFullNameRaw(), ''); + setFolderHash(FolderUserStore.currentFolderFullNameRaw(), ''); } if (bDropPagePosition) { - MessageStore.messageListPage(1); - MessageStore.messageListPageBeforeThread(1); + MessageUserStore.messageListPage(1); + MessageUserStore.messageListPageBeforeThread(1); iOffset = 0; rl.route.setHash( mailBox( - FolderStore.currentFolderFullNameHash(), - MessageStore.messageListPage(), - MessageStore.messageListSearch(), - MessageStore.messageListThreadUid() + FolderUserStore.currentFolderFullNameHash(), + MessageUserStore.messageListPage(), + MessageUserStore.messageListSearch(), + MessageUserStore.messageListThreadUid() ), true, true ); } - MessageStore.messageListLoading(true); + MessageUserStore.messageListLoading(true); Remote.messageList( (sResult, oData, bCached) => { if (StorageResultType.Success === sResult && oData && oData.Result) { - MessageStore.messageListError(''); - MessageStore.messageListLoading(false); + MessageUserStore.messageListError(''); + MessageUserStore.messageListLoading(false); - MessageStore.setMessageList(oData, bCached); + MessageUserStore.setMessageList(oData, bCached); } else if (StorageResultType.Unload === sResult) { - MessageStore.messageListError(''); - MessageStore.messageListLoading(false); + MessageUserStore.messageListError(''); + MessageUserStore.messageListLoading(false); } else if (StorageResultType.Abort !== sResult) { - MessageStore.messageList([]); - MessageStore.messageListLoading(false); - MessageStore.messageListError( + MessageUserStore.messageList([]); + MessageUserStore.messageListLoading(false); + MessageUserStore.messageListError( getNotification((oData && oData.ErrorCode) || Notification.CantGetMessageList) ); } }, - FolderStore.currentFolderFullNameRaw(), + FolderUserStore.currentFolderFullNameRaw(), iOffset, - SettingsStore.messagesPerPage(), - MessageStore.messageListSearch(), - MessageStore.messageListThreadUid() + SettingsUserStore.messagesPerPage(), + MessageUserStore.messageListSearch(), + MessageUserStore.messageListThreadUid() ); } recacheInboxMessageList() { - Remote.messageList(()=>{}, getFolderInboxName(), 0, SettingsStore.messagesPerPage(), '', '', true); + Remote.messageList(()=>{}, getFolderInboxName(), 0, SettingsUserStore.messagesPerPage(), '', '', true); } /** @@ -216,20 +216,19 @@ class AppUser extends AbstractApp { * @returns {boolean} */ contactsSync(fResultFunc) { - const oContacts = ContactStore.contacts; if ( - oContacts.importing() || - oContacts.syncing() || - !ContactStore.enableContactsSync() || - !ContactStore.allowContactsSync() + ContactUserStore.importing() || + ContactUserStore.syncing() || + !ContactUserStore.enableSync() || + !ContactUserStore.allowSync() ) { return false; } - oContacts.syncing(true); + ContactUserStore.syncing(true); Remote.contactsSync((sResult, oData) => { - oContacts.syncing(false); + ContactUserStore.syncing(false); if (fResultFunc) { fResultFunc(sResult, oData); @@ -240,8 +239,8 @@ class AppUser extends AbstractApp { } messagesMoveTrigger() { - const sTrashFolder = FolderStore.trashFolder(), - sSpamFolder = FolderStore.spamFolder(); + const sTrashFolder = FolderUserStore.trashFolder(), + sSpamFolder = FolderUserStore.spamFolder(); Object.values(this.moveCache).forEach(item => { const isSpam = sSpamFolder === item.To, @@ -284,18 +283,18 @@ class AppUser extends AbstractApp { } moveOrDeleteResponseHelper(sResult, oData) { - if (StorageResultType.Success === sResult && FolderStore.currentFolder()) { + if (StorageResultType.Success === sResult && FolderUserStore.currentFolder()) { if (oData && Array.isArray(oData.Result) && 2 === oData.Result.length) { setFolderHash(oData.Result[0], oData.Result[1]); } else { - setFolderHash(FolderStore.currentFolderFullNameRaw(), ''); + setFolderHash(FolderUserStore.currentFolderFullNameRaw(), ''); if (oData && [Notification.CantMoveMessage, Notification.CantCopyMessage].includes(oData.ErrorCode)) { alert(getNotification(oData.ErrorCode)); } } - this.reloadMessageList(!MessageStore.messageList.length); + this.reloadMessageList(!MessageUserStore.messageList.length); this.quotaDebounce(); } } @@ -306,7 +305,7 @@ class AppUser extends AbstractApp { */ deleteMessagesFromFolderWithoutCheck(sFromFolderFullNameRaw, aUidForRemove) { this.messagesDeleteHelper(sFromFolderFullNameRaw, aUidForRemove); - MessageStore.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove); + MessageUserStore.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove); } /** @@ -321,18 +320,18 @@ class AppUser extends AbstractApp { switch (iDeleteType) { case FolderType.Spam: - oMoveFolder = getFolderFromCacheList(FolderStore.spamFolder()); + oMoveFolder = getFolderFromCacheList(FolderUserStore.spamFolder()); nSetSystemFoldersNotification = SetSystemFoldersNotification.Spam; break; case FolderType.NotSpam: oMoveFolder = getFolderFromCacheList(getFolderInboxName()); break; case FolderType.Trash: - oMoveFolder = getFolderFromCacheList(FolderStore.trashFolder()); + oMoveFolder = getFolderFromCacheList(FolderUserStore.trashFolder()); nSetSystemFoldersNotification = SetSystemFoldersNotification.Trash; break; case FolderType.Archive: - oMoveFolder = getFolderFromCacheList(FolderStore.archiveFolder()); + oMoveFolder = getFolderFromCacheList(FolderUserStore.archiveFolder()); nSetSystemFoldersNotification = SetSystemFoldersNotification.Archive; break; // no default @@ -341,9 +340,9 @@ class AppUser extends AbstractApp { bUseFolder = undefined === bUseFolder ? true : !!bUseFolder; if (bUseFolder) { if ( - (FolderType.Spam === iDeleteType && UNUSED_OPTION_VALUE === FolderStore.spamFolder()) || - (FolderType.Trash === iDeleteType && UNUSED_OPTION_VALUE === FolderStore.trashFolder()) || - (FolderType.Archive === iDeleteType && UNUSED_OPTION_VALUE === FolderStore.archiveFolder()) + (FolderType.Spam === iDeleteType && UNUSED_OPTION_VALUE === FolderUserStore.spamFolder()) || + (FolderType.Trash === iDeleteType && UNUSED_OPTION_VALUE === FolderUserStore.trashFolder()) || + (FolderType.Archive === iDeleteType && UNUSED_OPTION_VALUE === FolderUserStore.archiveFolder()) ) { bUseFolder = false; } @@ -354,18 +353,19 @@ class AppUser extends AbstractApp { } else if ( !bUseFolder || (FolderType.Trash === iDeleteType && - (sFromFolderFullNameRaw === FolderStore.spamFolder() || sFromFolderFullNameRaw === FolderStore.trashFolder())) + (sFromFolderFullNameRaw === FolderUserStore.spamFolder() + || sFromFolderFullNameRaw === FolderUserStore.trashFolder())) ) { showScreenPopup(AskPopupView, [ i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), () => { this.messagesDeleteHelper(sFromFolderFullNameRaw, aUidForRemove); - MessageStore.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove); + MessageUserStore.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove); } ]); } else if (oMoveFolder) { this.messagesMoveHelper(sFromFolderFullNameRaw, oMoveFolder.fullNameRaw, aUidForRemove); - MessageStore.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove, oMoveFolder.fullNameRaw); + MessageUserStore.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove, oMoveFolder.fullNameRaw); } } @@ -387,7 +387,7 @@ class AppUser extends AbstractApp { this.messagesMoveHelper(oFromFolder.fullNameRaw, oToFolder.fullNameRaw, aUidForMove); } - MessageStore.removeMessagesFromList(oFromFolder.fullNameRaw, aUidForMove, oToFolder.fullNameRaw, bCopy); + MessageUserStore.removeMessagesFromList(oFromFolder.fullNameRaw, aUidForMove, oToFolder.fullNameRaw, bCopy); return true; } } @@ -409,17 +409,17 @@ class AppUser extends AbstractApp { .then( Remote.foldersReloadWithTimeout, errorCode => { - FolderStore.folderListError(getNotification(errorCode, '', errorDefCode)); + FolderUserStore.folderListError(getNotification(errorCode, '', errorDefCode)); Remote.foldersReloadWithTimeout(); } ); } reloadOpenPgpKeys() { - if (PgpStore.capaOpenPGP()) { + if (PgpUserStore.capaOpenPGP()) { const keys = [], email = new EmailModel(), - openpgpKeyring = PgpStore.openpgpKeyring, + openpgpKeyring = PgpUserStore.openpgpKeyring, openpgpKeys = openpgpKeyring ? openpgpKeyring.getAllKeys() : []; openpgpKeys.forEach((oItem, iIndex) => { @@ -470,32 +470,32 @@ class AppUser extends AbstractApp { } }); - delegateRunOnDestroy(PgpStore.openpgpkeys()); - PgpStore.openpgpkeys(keys); + delegateRunOnDestroy(PgpUserStore.openpgpkeys()); + PgpUserStore.openpgpkeys(keys); } } accountsAndIdentities() { - AccountStore.accounts.loading(true); + AccountUserStore.loading(true); IdentityUserStore.loading(true); Remote.accountsAndIdentities((sResult, oData) => { - AccountStore.accounts.loading(false); + AccountUserStore.loading(false); IdentityUserStore.loading(false); if (StorageResultType.Success === sResult && oData.Result) { const counts = {}, - sAccountEmail = AccountStore.email(); + sAccountEmail = AccountUserStore.email(); let parentEmail = SettingsGet('ParentEmail') || sAccountEmail; if (Array.isArray(oData.Result.Accounts)) { - AccountStore.accounts.forEach(oAccount => + AccountUserStore.accounts.forEach(oAccount => counts[oAccount.email] = oAccount.count() ); - delegateRunOnDestroy(AccountStore.accounts()); + delegateRunOnDestroy(AccountUserStore.accounts()); - AccountStore.accounts( + AccountUserStore.accounts( oData.Result.Accounts.map( sValue => new AccountModel(sValue, sValue !== parentEmail, counts[sValue] || 0) ) @@ -526,15 +526,15 @@ class AppUser extends AbstractApp { } templates() { - TemplateStore.templates.loading(true); + TemplateUserStore.templates.loading(true); Remote.templates((result, data) => { - TemplateStore.templates.loading(false); + TemplateUserStore.templates.loading(false); if (StorageResultType.Success === result && data.Result && Array.isArray(data.Result.Templates)) { - delegateRunOnDestroy(TemplateStore.templates()); + delegateRunOnDestroy(TemplateUserStore.templates()); - TemplateStore.templates( + TemplateUserStore.templates( data.Result.Templates.map(templateData => TemplateModel.reviveFromJson(templateData) ).filter(v => v) @@ -554,7 +554,7 @@ class AppUser extends AbstractApp { isPosNumeric(data.Result[0], true) && isPosNumeric(data.Result[1], true) ) { - QuotaStore.populateData(pInt(data.Result[1]), pInt(data.Result[0])); + QuotaUserStore.populateData(pInt(data.Result[1]), pInt(data.Result[0])); } }); } @@ -617,7 +617,7 @@ class AppUser extends AbstractApp { } } - MessageStore.initUidNextAndNewMessages( + MessageUserStore.initUidNextAndNewMessages( folderFromCache.fullNameRaw, data.Result.UidNext, data.Result.NewMessages @@ -625,7 +625,7 @@ class AppUser extends AbstractApp { const hash = getFolderHash(data.Result.Folder); if (!hash || unreadCountChange || data.Result.Hash !== hash) { - if (folderFromCache.fullNameRaw === FolderStore.currentFolderFullNameRaw()) { + if (folderFromCache.fullNameRaw === FolderUserStore.currentFolderFullNameRaw()) { this.reloadMessageList(); } else if (getFolderInboxName() === folderFromCache.fullNameRaw) { this.recacheInboxMessageList(); @@ -645,7 +645,7 @@ class AppUser extends AbstractApp { * @param {boolean=} boot = false */ folderInformationMultiply(boot = false) { - const folders = FolderStore.getNextFolderNames(); + const folders = FolderUserStore.getNextFolderNames(); if (Array.isNotEmpty(folders)) { Remote.folderInformationMultiply((sResult, oData) => { if (StorageResultType.Success === sResult) { @@ -680,13 +680,13 @@ class AppUser extends AbstractApp { } if (!hash || item.Hash !== hash) { - if (folder.fullNameRaw === FolderStore.currentFolderFullNameRaw()) { + if (folder.fullNameRaw === FolderUserStore.currentFolderFullNameRaw()) { this.reloadMessageList(); } } else if (unreadCountChange - && folder.fullNameRaw === FolderStore.currentFolderFullNameRaw() - && MessageStore.messageList.length) { - this.folderInformation(folder.fullNameRaw, MessageStore.messageList()); + && folder.fullNameRaw === FolderUserStore.currentFolderFullNameRaw() + && MessageUserStore.messageList.length) { + this.folderInformation(folder.fullNameRaw, MessageUserStore.messageList()); } } }); @@ -711,7 +711,7 @@ class AppUser extends AbstractApp { rootUids = []; if (undefined === messages || !messages) { - messages = MessageStore.messageListChecked(); + messages = MessageUserStore.messageListChecked(); } rootUids = messages.map(oMessage => oMessage && oMessage.uid ? oMessage.uid : null) @@ -764,7 +764,7 @@ class AppUser extends AbstractApp { } this.reloadFlagsCurrentMessageListAndMessageFromCache(); - MessageStore.messageViewTrigger(!MessageStore.messageViewTrigger()); + MessageUserStore.messageViewTrigger(!MessageUserStore.messageViewTrigger()); } } @@ -901,11 +901,11 @@ class AppUser extends AbstractApp { addEventListener('resize', () => leftPanelDisabled(ThemeStore.isMobile() || 1000 > innerWidth)); - AppStore.populate(); - SettingsStore.populate(); - NotificationStore.populate(); - AccountStore.populate(); - ContactStore.populate(); + AppUserStore.populate(); + SettingsUserStore.populate(); + NotificationUserStore.populate(); + AccountUserStore.populate(); + ContactUserStore.populate(); let contactsSyncInterval = pInt(SettingsGet('ContactsSyncInterval')); @@ -941,18 +941,18 @@ class AppUser extends AbstractApp { if (!window.openpgp) { return false; } - PgpStore.openpgp = openpgp; + PgpUserStore.openpgp = openpgp; if (window.Worker) { try { - PgpStore.openpgp.initWorker({ path: openPgpWorkerJs() }); + PgpUserStore.openpgp.initWorker({ path: openPgpWorkerJs() }); } catch (e) { console.error(e); } } - PgpStore.openpgpKeyring = new openpgp.Keyring(); - PgpStore.capaOpenPGP(true); + PgpUserStore.openpgpKeyring = new openpgp.Keyring(); + PgpUserStore.capaOpenPGP(true); this.reloadOpenPgpKeys(); @@ -966,7 +966,7 @@ class AppUser extends AbstractApp { doc.head.append(script); } } else { - PgpStore.capaOpenPGP(false); + PgpUserStore.capaOpenPGP(false); } startScreens([ @@ -977,7 +977,7 @@ class AppUser extends AbstractApp { // Every 5 minutes setInterval(() => { - const cF = FolderStore.currentFolderFullNameRaw(), + const cF = FolderUserStore.currentFolderFullNameRaw(), iF = getFolderInboxName(); this.folderInformation(iF); if (iF !== cF) { @@ -999,7 +999,7 @@ class AppUser extends AbstractApp { this.accountsAndIdentities(true); setTimeout(() => { - const cF = FolderStore.currentFolderFullNameRaw(); + const cF = FolderUserStore.currentFolderFullNameRaw(); if (getFolderInboxName() !== cF) { this.folderInformation(cF); } diff --git a/dev/Common/Audio.js b/dev/Common/Audio.js index 8c0b0df68..b541a4e5b 100644 --- a/dev/Common/Audio.js +++ b/dev/Common/Audio.js @@ -63,7 +63,7 @@ unlockEvents.forEach(type => doc.addEventListener(type, unlock, true)); * Browsers can't play without user interaction */ -const SMAudio = new class { +export const SMAudio = new class { constructor() { player || (player = createNewObject()); @@ -119,5 +119,3 @@ const SMAudio = new class { } } }; - -export default SMAudio; diff --git a/dev/Model/Attachment.js b/dev/Model/Attachment.js index 08bbb0591..880090761 100644 --- a/dev/Model/Attachment.js +++ b/dev/Model/Attachment.js @@ -8,7 +8,7 @@ import { import { AbstractModel } from 'Knoin/AbstractModel'; -import Audio from 'Common/Audio'; +import { SMAudio } from 'Common/Audio'; const bAllowPdfPreview = undefined !== navigator.mimeTypes['application/pdf']; @@ -120,9 +120,9 @@ export class AttachmentModel extends AbstractModel { */ hasPreplay() { return ( - (Audio.supportedMp3 && this.isMp3()) || - (Audio.supportedOgg && this.isOgg()) || - (Audio.supportedWav && this.isWav()) + (SMAudio.supportedMp3 && this.isMp3()) || + (SMAudio.supportedOgg && this.isOgg()) || + (SMAudio.supportedWav && this.isWav()) ); } diff --git a/dev/Model/Filter.js b/dev/Model/Filter.js index 938152a5c..35855bcae 100644 --- a/dev/Model/Filter.js +++ b/dev/Model/Filter.js @@ -5,7 +5,7 @@ import { delegateRunOnDestroy } from 'Common/UtilsUser'; import { i18n } from 'Common/Translator'; import { getFolderFromCacheList } from 'Common/Cache'; -import AccountStore from 'Stores/User/Account'; +import { AccountUserStore } from 'Stores/User/Account'; import { FilterConditionModel } from 'Model/FilterCondition'; import { AbstractModel } from 'Knoin/AbstractModel'; @@ -215,7 +215,7 @@ export class FilterModel extends AbstractModel { } setRecipients() { - this.actionValueFourth(AccountStore.getEmailAddresses().join(', ')); + this.actionValueFourth(AccountUserStore.getEmailAddresses().join(', ')); } /** diff --git a/dev/Model/FolderCollection.js b/dev/Model/FolderCollection.js index 52836d808..8b7e1eced 100644 --- a/dev/Model/FolderCollection.js +++ b/dev/Model/FolderCollection.js @@ -8,8 +8,8 @@ import { Settings, SettingsGet } from 'Common/Globals'; import * as Local from 'Storage/Client'; -import AppStore from 'Stores/User/App'; -import FolderStore from 'Stores/User/Folder'; +import { AppUserStore } from 'Stores/User/App'; +import { FolderUserStore } from 'Stores/User/Folder'; import ko from 'ko'; @@ -102,17 +102,17 @@ export class FolderCollectionModel extends AbstractCollectionModel let limit = pInt(Settings.app('folderSpecLimit')); limit = 100 < limit ? 100 : 10 > limit ? 10 : limit; - FolderStore.displaySpecSetting(0 >= cnt || limit < cnt); + FolderUserStore.displaySpecSetting(0 >= cnt || limit < cnt); - FolderStore.folderList(this); + FolderUserStore.folderList(this); if (undefined !== this.Namespace) { - FolderStore.namespace = this.Namespace; + FolderUserStore.namespace = this.Namespace; } - AppStore.threadsAllowed(!!(Settings.app('useImapThread') && this.IsThreadsSupported)); + AppUserStore.threadsAllowed(!!(Settings.app('useImapThread') && this.IsThreadsSupported)); - FolderStore.folderListOptimized(!!this.Optimized); + FolderUserStore.folderListOptimized(!!this.Optimized); let update = false; @@ -135,19 +135,19 @@ export class FolderCollectionModel extends AbstractCollectionModel update = true; } - FolderStore.sentFolder(normalizeFolder(SettingsGet('SentFolder'))); - FolderStore.draftFolder(normalizeFolder(SettingsGet('DraftFolder'))); - FolderStore.spamFolder(normalizeFolder(SettingsGet('SpamFolder'))); - FolderStore.trashFolder(normalizeFolder(SettingsGet('TrashFolder'))); - FolderStore.archiveFolder(normalizeFolder(SettingsGet('ArchiveFolder'))); + FolderUserStore.sentFolder(normalizeFolder(SettingsGet('SentFolder'))); + FolderUserStore.draftFolder(normalizeFolder(SettingsGet('DraftFolder'))); + FolderUserStore.spamFolder(normalizeFolder(SettingsGet('SpamFolder'))); + FolderUserStore.trashFolder(normalizeFolder(SettingsGet('TrashFolder'))); + FolderUserStore.archiveFolder(normalizeFolder(SettingsGet('ArchiveFolder'))); if (update) { rl.app.Remote.saveSystemFolders(()=>{}, { - SentFolder: FolderStore.sentFolder(), - DraftFolder: FolderStore.draftFolder(), - SpamFolder: FolderStore.spamFolder(), - TrashFolder: FolderStore.trashFolder(), - ArchiveFolder: FolderStore.archiveFolder(), + SentFolder: FolderUserStore.sentFolder(), + DraftFolder: FolderUserStore.draftFolder(), + SpamFolder: FolderUserStore.spamFolder(), + TrashFolder: FolderUserStore.trashFolder(), + ArchiveFolder: FolderUserStore.archiveFolder(), NullFolder: 'NullFolder' }); } diff --git a/dev/Model/Message.js b/dev/Model/Message.js index dcfdc2cb3..7ce42faf8 100644 --- a/dev/Model/Message.js +++ b/dev/Model/Message.js @@ -8,7 +8,7 @@ import { isArray } from 'Common/Utils'; import { serverRequestRaw } from 'Common/Links'; -import FolderStore from 'Stores/User/Folder'; +import { FolderUserStore } from 'Stores/User/Folder'; import { FileInfo } from 'Common/File'; import { AttachmentCollectionModel } from 'Model/AttachmentCollection'; @@ -173,7 +173,7 @@ export class MessageModel extends AbstractModel { } computeSenderEmail() { - const list = [FolderStore.sentFolder(), FolderStore.draftFolder()].includes(this.folder) ? 'to' : 'from'; + const list = [FolderUserStore.sentFolder(), FolderUserStore.draftFolder()].includes(this.folder) ? 'to' : 'from'; this.senderEmailsString(this[list].toString(true)); this.senderClearEmailsString(this[list].toStringClear()); } diff --git a/dev/Model/OpenPgpKey.js b/dev/Model/OpenPgpKey.js index ff30d091c..36bebd18e 100644 --- a/dev/Model/OpenPgpKey.js +++ b/dev/Model/OpenPgpKey.js @@ -2,7 +2,7 @@ import ko from 'ko'; import { AbstractModel } from 'Knoin/AbstractModel'; -import PgpStore from 'Stores/User/Pgp'; +import { PgpUserStore } from 'Stores/User/Pgp'; export class OpenPgpKeyModel extends AbstractModel { /** @@ -38,7 +38,7 @@ export class OpenPgpKeyModel extends AbstractModel { getNativeKey() { let key = null; try { - key = PgpStore.openpgp.key.readArmored(this.armor); + key = PgpUserStore.openpgp.key.readArmored(this.armor); if (key && !key.err && key.keys && key.keys[0]) { return key; } diff --git a/dev/Remote/User/Fetch.js b/dev/Remote/User/Fetch.js index 68ea80c55..edbe0b2d2 100644 --- a/dev/Remote/User/Fetch.js +++ b/dev/Remote/User/Fetch.js @@ -11,9 +11,9 @@ import { import { SettingsGet } from 'Common/Globals'; import { SUB_QUERY_PREFIX } from 'Common/Links'; -import AppStore from 'Stores/User/App'; -import SettingsStore from 'Stores/User/Settings'; -import FolderStore from 'Stores/User/Folder'; +import { AppUserStore } from 'Stores/User/App'; +import { SettingsUserStore } from 'Stores/User/Settings'; +import { FolderUserStore } from 'Stores/User/Folder'; import { AbstractFetchRemote } from 'Remote/AbstractFetch'; @@ -308,7 +308,7 @@ class RemoteUserFetch extends AbstractFetchRemote { sFolderFullNameRaw = pString(sFolderFullNameRaw); const folderHash = getFolderHash(sFolderFullNameRaw), - useThreads = AppStore.threadsAllowed() && SettingsStore.useThreads(), + useThreads = AppUserStore.threadsAllowed() && SettingsUserStore.useThreads(), inboxUidNext = getFolderInboxName() === sFolderFullNameRaw ? getFolderUidNext(sFolderFullNameRaw) : ''; let params = {}, sGetAdd = ''; @@ -322,7 +322,7 @@ class RemoteUserFetch extends AbstractFetchRemote { iOffset, iLimit, sSearch, - AppStore.projectHash(), + AppUserStore.projectHash(), folderHash, inboxUidNext, useThreads ? 1 : 0, @@ -387,8 +387,8 @@ class RemoteUserFetch extends AbstractFetchRemote { urlsafeArray([ sFolderFullNameRaw, iUid, - AppStore.projectHash(), - AppStore.threadsAllowed() && SettingsStore.useThreads() ? 1 : 0 + AppUserStore.projectHash(), + AppUserStore.threadsAllowed() && SettingsUserStore.useThreads() ? 1 : 0 ]), ['Message'] ); @@ -467,7 +467,7 @@ class RemoteUserFetch extends AbstractFetchRemote { FlagsUids: Array.isArray(uids) ? uids.join(',') : '', UidNext: getFolderInboxName() === folder ? getFolderUidNext(folder) : '' }); - } else if (SettingsStore.useThreads()) { + } else if (SettingsUserStore.useThreads()) { rl.app.reloadFlagsCurrentMessageListAndMessageFromCache(); } } @@ -773,7 +773,7 @@ class RemoteUserFetch extends AbstractFetchRemote { foldersReload(fCallback) { this.abort('Folders') - .postRequest('Folders', FolderStore.foldersLoading) + .postRequest('Folders', FolderUserStore.foldersLoading) .then(data => { data = FolderCollectionModel.reviveFromJson(data.Result); data && data.storeIt(); @@ -783,27 +783,27 @@ class RemoteUserFetch extends AbstractFetchRemote { } foldersReloadWithTimeout() { - this.setTrigger(FolderStore.foldersLoading, true); + this.setTrigger(FolderUserStore.foldersLoading, true); clearTimeout(this.foldersTimeout); this.foldersTimeout = setTimeout(() => this.foldersReload(), 500); } folderDelete(sFolderFullNameRaw) { - return this.postRequest('FolderDelete', FolderStore.foldersDeleting, { + return this.postRequest('FolderDelete', FolderUserStore.foldersDeleting, { Folder: sFolderFullNameRaw }); } folderCreate(sNewFolderName, sParentName) { - return this.postRequest('FolderCreate', FolderStore.foldersCreating, { + return this.postRequest('FolderCreate', FolderUserStore.foldersCreating, { Folder: sNewFolderName, Parent: sParentName }); } folderRename(sPrevFolderFullNameRaw, sNewFolderName) { - return this.postRequest('FolderRename', FolderStore.foldersRenaming, { + return this.postRequest('FolderRename', FolderUserStore.foldersRenaming, { Folder: sPrevFolderFullNameRaw, NewFolderName: sNewFolderName }); diff --git a/dev/Screen/User/MailBox.js b/dev/Screen/User/MailBox.js index a5f1827f0..bf7548c0d 100644 --- a/dev/Screen/User/MailBox.js +++ b/dev/Screen/User/MailBox.js @@ -4,11 +4,11 @@ import { pString, pInt } from 'Common/Utils'; import { getFolderFromCacheList, getFolderFullNameRaw, getFolderInboxName } from 'Common/Cache'; import { i18n } from 'Common/Translator'; -import AppStore from 'Stores/User/App'; -import AccountStore from 'Stores/User/Account'; -import SettingsStore from 'Stores/User/Settings'; -import FolderStore from 'Stores/User/Folder'; -import MessageStore from 'Stores/User/Message'; +import { AppUserStore } from 'Stores/User/App'; +import { AccountUserStore } from 'Stores/User/Account'; +import { SettingsUserStore } from 'Stores/User/Settings'; +import { FolderUserStore } from 'Stores/User/Folder'; +import { MessageUserStore } from 'Stores/User/Message'; import { ThemeStore } from 'Stores/Theme'; import { SystemDropDownMailBoxUserView } from 'View/User/MailBox/SystemDropDown'; @@ -36,12 +36,12 @@ export class MailBoxUserScreen extends AbstractScreen { * @returns {void} */ updateWindowTitle() { - const foldersInboxUnreadCount = Settings.app('listPermanentFiltered') ? 0 : FolderStore.foldersInboxUnreadCount(), - email = AccountStore.email(); + const count = Settings.app('listPermanentFiltered') ? 0 : FolderUserStore.foldersInboxUnreadCount(), + email = AccountUserStore.email(); rl.setWindowTitle( (email - ? '' + (0 < foldersInboxUnreadCount ? '(' + foldersInboxUnreadCount + ') ' : ' ') + email + ' - ' + ? '' + (0 < count ? '(' + count + ') ' : ' ') + email + ' - ' : '' ) + i18n('TITLES/MAILBOX') ); @@ -53,8 +53,8 @@ export class MailBoxUserScreen extends AbstractScreen { onShow() { this.updateWindowTitle(); - AppStore.focusedState(Focused.None); - AppStore.focusedState(Focused.MessageList); + AppUserStore.focusedState(Focused.None); + AppUserStore.focusedState(Focused.MessageList); ThemeStore.isMobile() && leftPanelDisabled(true); } @@ -73,11 +73,11 @@ export class MailBoxUserScreen extends AbstractScreen { threadUid = ''; } - FolderStore.currentFolder(folder); + FolderUserStore.currentFolder(folder); - MessageStore.messageListPage(page); - MessageStore.messageListSearch(search); - MessageStore.messageListThreadUid(threadUid); + MessageUserStore.messageListPage(page); + MessageUserStore.messageListSearch(search); + MessageUserStore.messageListThreadUid(threadUid); rl.app.reloadMessageList(); } @@ -89,14 +89,14 @@ export class MailBoxUserScreen extends AbstractScreen { onStart() { if (!this.__started) { super.onStart(); - setTimeout(() => SettingsStore.layout.valueHasMutated(), 50); + setTimeout(() => SettingsUserStore.layout.valueHasMutated(), 50); setTimeout(() => warmUpScreenPopup(ComposePopupView), 500); addEventListener('mailbox.inbox-unread-count', e => { - FolderStore.foldersInboxUnreadCount(e.detail); + FolderUserStore.foldersInboxUnreadCount(e.detail); - const email = AccountStore.email(); - AccountStore.accounts.forEach(item => + const email = AccountUserStore.email(); + AccountUserStore.accounts.forEach(item => item && email === item.email && item.count(e.detail) ); diff --git a/dev/Screen/User/Settings.js b/dev/Screen/User/Settings.js index 52b0e6531..8b36419c2 100644 --- a/dev/Screen/User/Settings.js +++ b/dev/Screen/User/Settings.js @@ -3,8 +3,8 @@ import { keyScope, leftPanelDisabled, Settings } from 'Common/Globals'; import { runSettingsViewModelHooks } from 'Common/Plugins'; import { initOnStartOrLangChange, i18n } from 'Common/Translator'; -import AppStore from 'Stores/User/App'; -import AccountStore from 'Stores/User/Account'; +import { AppUserStore } from 'Stores/User/App'; +import { AccountUserStore } from 'Stores/User/Account'; import { ThemeStore } from 'Stores/Theme'; import { AbstractSettingsScreen, settingsAddViewModel } from 'Screen/AbstractSettings'; @@ -45,7 +45,7 @@ export class SettingsUserScreen extends AbstractSettingsScreen { settingsAddViewModel(GeneralUserSettings, 'SettingsGeneral', 'SETTINGS_LABELS/LABEL_GENERAL_NAME', 'general', true); - if (AppStore.contactsIsAllowed()) { + if (AppUserStore.contactsIsAllowed()) { settingsAddViewModel(ContactsUserSettings, 'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts'); } @@ -101,7 +101,7 @@ export class SettingsUserScreen extends AbstractSettingsScreen { } setSettingsTitle() { - const sEmail = AccountStore.email(); + const sEmail = AccountUserStore.email(); rl.setWindowTitle((sEmail ? sEmail + ' - ' : '') + this.sSettingsTitle); } } diff --git a/dev/Settings/User/Accounts.js b/dev/Settings/User/Accounts.js index ba75cdbba..5b18a9f74 100644 --- a/dev/Settings/User/Accounts.js +++ b/dev/Settings/User/Accounts.js @@ -3,7 +3,7 @@ import ko from 'ko'; import { Capa, StorageResultType } from 'Common/Enums'; import { Settings } from 'Common/Globals'; -import AccountStore from 'Stores/User/Account'; +import { AccountUserStore } from 'Stores/User/Account'; import { IdentityUserStore } from 'Stores/User/Identity'; import Remote from 'Remote/User/Fetch'; @@ -17,7 +17,8 @@ export class AccountsUserSettings { this.allowAdditionalAccount = Settings.capa(Capa.AdditionalAccounts); this.allowIdentities = Settings.capa(Capa.Identities); - this.accounts = AccountStore.accounts; + this.accounts = AccountUserStore.accounts; + this.loading = AccountUserStore.loading; this.identities = IdentityUserStore; this.accountForDeletion = ko.observable(null).deleteAccessHelper(); @@ -80,7 +81,7 @@ export class AccountsUserSettings { } accountsAndIdentitiesAfterMove() { - Remote.accountsAndIdentitiesSortOrder(null, AccountStore.getEmailAddresses(), IdentityUserStore.getIDS()); + Remote.accountsAndIdentitiesSortOrder(null, AccountUserStore.getEmailAddresses(), IdentityUserStore.getIDS()); } onBuild(oDom) { diff --git a/dev/Settings/User/Contacts.js b/dev/Settings/User/Contacts.js index 061deec97..7e39e4729 100644 --- a/dev/Settings/User/Contacts.js +++ b/dev/Settings/User/Contacts.js @@ -1,26 +1,26 @@ import ko from 'ko'; -import AppStore from 'Stores/User/App'; -import ContactStore from 'Stores/User/Contact'; +import { AppUserStore } from 'Stores/User/App'; +import { ContactUserStore } from 'Stores/User/Contact'; import Remote from 'Remote/User/Fetch'; export class ContactsUserSettings { constructor() { - this.contactsAutosave = AppStore.contactsAutosave; + this.contactsAutosave = AppUserStore.contactsAutosave; - this.allowContactsSync = ContactStore.allowContactsSync; - this.enableContactsSync = ContactStore.enableContactsSync; - this.contactsSyncUrl = ContactStore.contactsSyncUrl; - this.contactsSyncUser = ContactStore.contactsSyncUser; - this.contactsSyncPass = ContactStore.contactsSyncPass; + this.allowContactsSync = ContactUserStore.allowSync; + this.enableContactsSync = ContactUserStore.enableSync; + this.contactsSyncUrl = ContactUserStore.syncUrl; + this.contactsSyncUser = ContactUserStore.syncUser; + this.contactsSyncPass = ContactUserStore.syncPass; this.saveTrigger = ko .computed(() => [ - this.enableContactsSync() ? '1' : '0', - this.contactsSyncUrl(), - this.contactsSyncUser(), - this.contactsSyncPass() + ContactUserStore.enableSync() ? '1' : '0', + ContactUserStore.syncUrl(), + ContactUserStore.syncUser(), + ContactUserStore.syncPass() ].join('|') ) .extend({ debounce: 500 }); @@ -36,10 +36,10 @@ export class ContactsUserSettings { this.saveTrigger.subscribe(() => { Remote.saveContactsSyncData( null, - this.enableContactsSync(), - this.contactsSyncUrl(), - this.contactsSyncUser(), - this.contactsSyncPass() + ContactUserStore.enableSync(), + ContactUserStore.syncUrl(), + ContactUserStore.syncUser(), + ContactUserStore.syncPass() ); }); } diff --git a/dev/Settings/User/Folders.js b/dev/Settings/User/Folders.js index 09c38b949..e51ada363 100644 --- a/dev/Settings/User/Folders.js +++ b/dev/Settings/User/Folders.js @@ -8,7 +8,7 @@ import { removeFolderFromCacheList } from 'Common/Cache'; import * as Local from 'Storage/Client'; -import FolderStore from 'Stores/User/Folder'; +import { FolderUserStore } from 'Stores/User/Folder'; import Remote from 'Remote/User/Fetch'; @@ -19,16 +19,16 @@ import { FolderSystemPopupView } from 'View/Popup/FolderSystem'; export class FoldersUserSettings { constructor() { - this.displaySpecSetting = FolderStore.displaySpecSetting; - this.folderList = FolderStore.folderList; - this.folderListOptimized = FolderStore.folderListOptimized; - this.folderListError = FolderStore.folderListError; + this.displaySpecSetting = FolderUserStore.displaySpecSetting; + this.folderList = FolderUserStore.folderList; + this.folderListOptimized = FolderUserStore.folderListOptimized; + this.folderListError = FolderUserStore.folderListError; this.loading = ko.computed(() => { - const loading = FolderStore.foldersLoading(), - creating = FolderStore.foldersCreating(), - deleting = FolderStore.foldersDeleting(), - renaming = FolderStore.foldersRenaming(); + const loading = FolderUserStore.foldersLoading(), + creating = FolderUserStore.foldersCreating(), + deleting = FolderUserStore.foldersDeleting(), + renaming = FolderUserStore.foldersRenaming(); return loading || creating || deleting || renaming; }); @@ -64,7 +64,7 @@ export class FoldersUserSettings { } onShow() { - FolderStore.folderListError(''); + FolderUserStore.folderListError(''); } /* onBuild(oDom) { @@ -98,7 +98,7 @@ export class FoldersUserSettings { Local.set(ClientSideKeyName.FoldersLashHash, ''); - FolderStore.folderList.remove(fRemoveFolder); + FolderUserStore.folderList.remove(fRemoveFolder); rl.app.foldersPromisesActionHelper( Remote.folderDelete(folderToRemove.fullNameRaw), @@ -108,7 +108,7 @@ export class FoldersUserSettings { removeFolderFromCacheList(folderToRemove.fullNameRaw); } } else if (0 < folderToRemove.privateMessageCountAll()) { - FolderStore.folderListError(getNotification(Notification.CantDeleteNonEmptyFolder)); + FolderUserStore.folderListError(getNotification(Notification.CantDeleteNonEmptyFolder)); } } diff --git a/dev/Settings/User/General.js b/dev/Settings/User/General.js index bba24a97e..4289c67e3 100644 --- a/dev/Settings/User/General.js +++ b/dev/Settings/User/General.js @@ -9,12 +9,12 @@ import { i18n, trigger as translatorTrigger, reload as translatorReload, convert import { showScreenPopup } from 'Knoin/Knoin'; -import AppStore from 'Stores/User/App'; +import { AppUserStore } from 'Stores/User/App'; import { LanguageStore } from 'Stores/Language'; -import SettingsStore from 'Stores/User/Settings'; +import { SettingsUserStore } from 'Stores/User/Settings'; import { IdentityUserStore } from 'Stores/User/Identity'; -import NotificationStore from 'Stores/User/Notification'; -import MessageStore from 'Stores/User/Message'; +import { NotificationUserStore } from 'Stores/User/Notification'; +import { MessageUserStore } from 'Stores/User/Message'; import Remote from 'Remote/User/Fetch'; @@ -25,23 +25,23 @@ export class GeneralUserSettings { constructor() { this.language = LanguageStore.language; this.languages = LanguageStore.languages; - this.messagesPerPage = SettingsStore.messagesPerPage; + this.messagesPerPage = SettingsUserStore.messagesPerPage; this.messagesPerPageArray = MESSAGES_PER_PAGE_VALUES; - this.editorDefaultType = SettingsStore.editorDefaultType; - this.layout = SettingsStore.layout; + this.editorDefaultType = SettingsUserStore.editorDefaultType; + this.layout = SettingsUserStore.layout; - this.enableSoundNotification = NotificationStore.enableSoundNotification; + this.enableSoundNotification = NotificationUserStore.enableSoundNotification; - this.enableDesktopNotification = NotificationStore.enableDesktopNotification; - this.isDesktopNotificationDenied = NotificationStore.isDesktopNotificationDenied; + this.enableDesktopNotification = NotificationUserStore.enableDesktopNotification; + this.isDesktopNotificationDenied = NotificationUserStore.isDesktopNotificationDenied; - this.showImages = SettingsStore.showImages; - this.removeColors = SettingsStore.removeColors; - this.useCheckboxesInList = SettingsStore.useCheckboxesInList; - this.threadsAllowed = AppStore.threadsAllowed; - this.useThreads = SettingsStore.useThreads; - this.replySameFolder = SettingsStore.replySameFolder; + this.showImages = SettingsUserStore.showImages; + this.removeColors = SettingsUserStore.removeColors; + this.useCheckboxesInList = SettingsUserStore.useCheckboxesInList; + this.threadsAllowed = AppUserStore.threadsAllowed; + this.useThreads = SettingsUserStore.useThreads; + this.replySameFolder = SettingsUserStore.replySameFolder; this.allowLanguagesOnSettings = !!SettingsGet('AllowLanguagesOnSettings'); this.languageFullName = ko.computed(() => convertLangName(this.language())); @@ -93,11 +93,11 @@ export class GeneralUserSettings { } testSoundNotification() { - NotificationStore.playSoundNotification(true); + NotificationUserStore.playSoundNotification(true); } testSystemNotification() { - NotificationStore.displayDesktopNotification('SnappyMail', 'Test notification', { }); + NotificationUserStore.displayDesktopNotification('SnappyMail', 'Test notification', { }); } onBuild() { @@ -147,14 +147,14 @@ export class GeneralUserSettings { ).debounce(3000)); this.useThreads.subscribe((value) => { - MessageStore.messageList([]); + MessageUserStore.messageList([]); Remote.saveSettings(null, { 'UseThreads': value ? 1 : 0 }); }); this.layout.subscribe((value) => { - MessageStore.messageList([]); + MessageUserStore.messageList([]); Remote.saveSettings(f2, { 'Layout': value }); diff --git a/dev/Settings/User/OpenPgp.js b/dev/Settings/User/OpenPgp.js index 5ac68d0e5..a6427ca06 100644 --- a/dev/Settings/User/OpenPgp.js +++ b/dev/Settings/User/OpenPgp.js @@ -2,8 +2,8 @@ import ko from 'ko'; import { delegateRunOnDestroy } from 'Common/UtilsUser'; -import PgpStore from 'Stores/User/Pgp'; -import SettingsStore from 'Stores/User/Settings'; +import { PgpUserStore } from 'Stores/User/Pgp'; +import { SettingsUserStore } from 'Stores/User/Settings'; import Remote from 'Remote/User/Fetch'; @@ -15,13 +15,13 @@ import { ViewOpenPgpKeyPopupView } from 'View/Popup/ViewOpenPgpKey'; export class OpenPgpUserSettings { constructor() { - this.openpgpkeys = PgpStore.openpgpkeys; - this.openpgpkeysPublic = PgpStore.openpgpkeysPublic; - this.openpgpkeysPrivate = PgpStore.openpgpkeysPrivate; + this.openpgpkeys = PgpUserStore.openpgpkeys; + this.openpgpkeysPublic = PgpUserStore.openpgpkeysPublic; + this.openpgpkeysPrivate = PgpUserStore.openpgpkeysPrivate; this.openPgpKeyForDeletion = ko.observable(null).deleteAccessHelper(); - this.allowDraftAutosave = SettingsStore.allowDraftAutosave; + this.allowDraftAutosave = SettingsUserStore.allowDraftAutosave; } addOpenPgpKey() { @@ -46,15 +46,15 @@ export class OpenPgpUserSettings { if (openPgpKeyToRemove && openPgpKeyToRemove.deleteAccess()) { this.openPgpKeyForDeletion(null); - if (openPgpKeyToRemove && PgpStore.openpgpKeyring) { - const findedItem = PgpStore.openpgpkeys.find(key => openPgpKeyToRemove === key); + if (openPgpKeyToRemove && PgpUserStore.openpgpKeyring) { + const findedItem = PgpUserStore.openpgpkeys.find(key => openPgpKeyToRemove === key); if (findedItem) { - PgpStore.openpgpkeys.remove(findedItem); + PgpUserStore.openpgpkeys.remove(findedItem); delegateRunOnDestroy(findedItem); - PgpStore.openpgpKeyring[findedItem.isPrivate ? 'privateKeys' : 'publicKeys'].removeForId(findedItem.guid); + PgpUserStore.openpgpKeyring[findedItem.isPrivate ? 'privateKeys' : 'publicKeys'].removeForId(findedItem.guid); - PgpStore.openpgpKeyring.store(); + PgpUserStore.openpgpKeyring.store(); } rl.app.reloadOpenPgpKeys(); diff --git a/dev/Settings/User/Security.js b/dev/Settings/User/Security.js index 2d07a9244..6d12fe73c 100644 --- a/dev/Settings/User/Security.js +++ b/dev/Settings/User/Security.js @@ -7,7 +7,7 @@ import { i18n, trigger as translatorTrigger } from 'Common/Translator'; import { showScreenPopup } from 'Knoin/Knoin'; -import SettinsStore from 'Stores/User/Settings'; +import { SettingsUserStore } from 'Stores/User/Settings'; import Remote from 'Remote/User/Fetch'; @@ -18,7 +18,7 @@ export class SecurityUserSettings { this.capaAutoLogout = Settings.capa(Capa.AutoLogout); this.capaTwoFactor = Settings.capa(Capa.TwoFactor); - this.autoLogout = SettinsStore.autoLogout; + this.autoLogout = SettingsUserStore.autoLogout; this.autoLogout.trigger = ko.observable(SaveSettingsStep.Idle); let i18nLogout = (key, params) => i18n('SETTINGS_SECURITY/AUTOLOGIN_' + key, params); diff --git a/dev/Settings/User/Templates.js b/dev/Settings/User/Templates.js index 534ec3a56..ad7b45981 100644 --- a/dev/Settings/User/Templates.js +++ b/dev/Settings/User/Templates.js @@ -2,7 +2,7 @@ import ko from 'ko'; import { i18n } from 'Common/Translator'; -import TemplateStore from 'Stores/User/Template'; +import { TemplateUserStore } from 'Stores/User/Template'; import Remote from 'Remote/User/Fetch'; import { showScreenPopup } from 'Knoin/Knoin'; @@ -11,10 +11,10 @@ import { TemplatePopupView } from 'View/Popup/Template'; export class TemplatesUserSettings { constructor() { - this.templates = TemplateStore.templates; + this.templates = TemplateUserStore.templates; this.processText = ko.computed(() => - TemplateStore.templates.loading() ? i18n('SETTINGS_TEMPLETS/LOADING_PROCESS') : '' + TemplateUserStore.templates.loading() ? i18n('SETTINGS_TEMPLETS/LOADING_PROCESS') : '' ); this.visibility = ko.computed(() => this.processText() ? 'visible' : 'hidden'); diff --git a/dev/Stores/User/Account.js b/dev/Stores/User/Account.js index 0cafc5fee..54cc2a074 100644 --- a/dev/Stores/User/Account.js +++ b/dev/Stores/User/Account.js @@ -1,36 +1,31 @@ import ko from 'ko'; import { SettingsGet } from 'Common/Globals'; -class AccountUserStore { - constructor() { - ko.addObservablesTo(this, { - email: '', - parentEmail: '', - signature: '' - }); +export const AccountUserStore = { + accounts: ko.observableArray(), + loading: ko.observable(false).extend({ debounce: 100 }), - this.accounts = ko.observableArray(); - this.accounts.loading = ko.observable(false).extend({ debounce: 100 }); + getEmailAddresses: () => AccountUserStore.accounts.map(item => item ? item.email : null).filter(v => v), - this.getEmailAddresses = () => this.accounts.map(item => item ? item.email : null).filter(v => v); + accountsUnreadCount: ko.computed(() => 0), + // accountsUnreadCount: ko.computed(() => { + // let result = 0; + // AccountUserStore.accounts().forEach(item => { + // if (item) { + // result += item.count(); + // } + // }); + // return result; + // }), - this.accountsUnreadCount = ko.computed(() => 0); - // this.accountsUnreadCount = ko.computed(() => { - // let result = 0; - // this.accounts().forEach(item => { - // if (item) - // { - // result += item.count(); - // } - // }); - // return result; - // }); + populate: () => { + AccountUserStore.email(SettingsGet('Email')); + AccountUserStore.parentEmail(SettingsGet('ParentEmail')); } +}; - populate() { - this.email(SettingsGet('Email')); - this.parentEmail(SettingsGet('ParentEmail')); - } -} - -export default new AccountUserStore(); +ko.addObservablesTo(AccountUserStore, { + email: '', + parentEmail: '', + signature: '' +}); diff --git a/dev/Stores/User/App.js b/dev/Stores/User/App.js index 80d5401ab..f2e5edac1 100644 --- a/dev/Stores/User/App.js +++ b/dev/Stores/User/App.js @@ -4,63 +4,59 @@ import { Focused } from 'Common/EnumsUser'; import { keyScope, leftPanelDisabled, Settings, SettingsGet } from 'Common/Globals'; import { ThemeStore } from 'Stores/Theme'; -class AppUserStore { - constructor() { - ko.addObservablesTo(this, { - currentAudio: '', +export const AppUserStore = { + attachmentsActions: ko.observableArray(), - focusedState: Focused.None, + devEmail: '', + devPassword: '', - projectHash: '', - threadsAllowed: false, + populate: () => { + AppUserStore.projectHash(SettingsGet('ProjectHash')); - composeInEdit: false, + AppUserStore.contactsAutosave(!!SettingsGet('ContactsAutosave')); + AppUserStore.useLocalProxyForExternalImages(!!SettingsGet('UseLocalProxyForExternalImages')); - contactsAutosave: false, - useLocalProxyForExternalImages: false, - - contactsIsAllowed: false - }); - - this.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; - } - }); - - this.attachmentsActions = ko.observableArray(); - - this.devEmail = ''; - this.devPassword = ''; - } - - populate() { - this.projectHash(SettingsGet('ProjectHash')); - - this.contactsAutosave(!!SettingsGet('ContactsAutosave')); - this.useLocalProxyForExternalImages(!!SettingsGet('UseLocalProxyForExternalImages')); - - this.contactsIsAllowed(!!SettingsGet('ContactsIsAllowed')); + AppUserStore.contactsIsAllowed(!!SettingsGet('ContactsIsAllowed')); const attachmentsActions = Settings.app('attachmentsActions'); - this.attachmentsActions(Array.isNotEmpty(attachmentsActions) ? attachmentsActions : []); + AppUserStore.attachmentsActions(Array.isNotEmpty(attachmentsActions) ? attachmentsActions : []); - this.devEmail = SettingsGet('DevEmail'); - this.devPassword = SettingsGet('DevPassword'); + AppUserStore.devEmail = SettingsGet('DevEmail'); + AppUserStore.devPassword = SettingsGet('DevPassword'); } -} +}; -export default new AppUserStore(); +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; + } +}); diff --git a/dev/Stores/User/Contact.js b/dev/Stores/User/Contact.js index 04c6e75a3..51c601c7a 100644 --- a/dev/Stores/User/Contact.js +++ b/dev/Stores/User/Contact.js @@ -1,32 +1,25 @@ import ko from 'ko'; import { SettingsGet } from 'Common/Globals'; -class ContactUserStore { - constructor() { - this.contacts = ko.observableArray(); - this.contacts.loading = ko.observable(false).extend({ debounce: 200 }); - this.contacts.importing = ko.observable(false).extend({ debounce: 200 }); - this.contacts.syncing = ko.observable(false).extend({ debounce: 200 }); - this.contacts.exportingVcf = ko.observable(false).extend({ debounce: 200 }); - this.contacts.exportingCsv = ko.observable(false).extend({ debounce: 200 }); +export const ContactUserStore = ko.observableArray(); - ko.addObservablesTo(this, { - allowContactsSync: false, - enableContactsSync: false, - contactsSyncUrl: '', - contactsSyncUser: '', - contactsSyncPass: '' - }); - } +ContactUserStore.loading = ko.observable(false).extend({ debounce: 200 }); +ContactUserStore.importing = ko.observable(false).extend({ debounce: 200 }); +ContactUserStore.syncing = ko.observable(false).extend({ debounce: 200 }); - populate() { - this.allowContactsSync(!!SettingsGet('ContactsSyncIsAllowed')); - this.enableContactsSync(!!SettingsGet('EnableContactsSync')); +ko.addObservablesTo(ContactUserStore, { + allowSync: false, + enableSync: false, + syncUrl: '', + syncUser: '', + syncPass: '' +}); - this.contactsSyncUrl(SettingsGet('ContactsSyncUrl')); - this.contactsSyncUser(SettingsGet('ContactsSyncUser')); - this.contactsSyncPass(SettingsGet('ContactsSyncPassword')); - } -} +ContactUserStore.populate = function() { + this.allowSync(!!SettingsGet('ContactsSyncIsAllowed')); + this.enableSync(!!SettingsGet('EnableContactsSync')); -export default new ContactUserStore(); + this.syncUrl(SettingsGet('ContactsSyncUrl')); + this.syncUser(SettingsGet('ContactsSyncUser')); + this.syncPass(SettingsGet('ContactsSyncPassword')); +}; diff --git a/dev/Stores/User/Folder.js b/dev/Stores/User/Folder.js index 8aa15690f..538c392a8 100644 --- a/dev/Stores/User/Folder.js +++ b/dev/Stores/User/Folder.js @@ -6,7 +6,7 @@ import { folderListOptionsBuilder } from 'Common/UtilsUser'; import { getFolderInboxName, getFolderFromCacheList } from 'Common/Cache'; import { SettingsGet } from 'Common/Globals'; -class FolderUserStore { +export const FolderUserStore = new class { constructor() { ko.addObservablesTo(this, { /** @@ -124,10 +124,6 @@ class FolderUserStore { ) ); - this.subscribers(); - } - - subscribers() { const fRemoveSystemFolderType = (observable) => () => { const folder = getFolderFromCacheList(observable()); if (folder) { @@ -200,6 +196,4 @@ class FolderUserStore { return result.filter((value, index, self) => self.indexOf(value) == index); } -} - -export default new FolderUserStore(); +}; diff --git a/dev/Stores/User/Message.js b/dev/Stores/User/Message.js index 492ba8c5e..1d5be8264 100644 --- a/dev/Stores/User/Message.js +++ b/dev/Stores/User/Message.js @@ -24,12 +24,12 @@ import { EmailCollectionModel } from 'Model/EmailCollection'; import { MessageModel } from 'Model/Message'; import { MessageCollectionModel } from 'Model/MessageCollection'; -import AppStore from 'Stores/User/App'; -import AccountStore from 'Stores/User/Account'; -import FolderStore from 'Stores/User/Folder'; -import PgpStore from 'Stores/User/Pgp'; -import SettingsStore from 'Stores/User/Settings'; -import NotificationStore from 'Stores/User/Notification'; +import { AppUserStore } from 'Stores/User/App'; +import { AccountUserStore } from 'Stores/User/Account'; +import { FolderUserStore } from 'Stores/User/Folder'; +import { PgpUserStore } from 'Stores/User/Pgp'; +import { SettingsUserStore } from 'Stores/User/Settings'; +import { NotificationUserStore } from 'Stores/User/Notification'; import Remote from 'Remote/User/Fetch'; @@ -66,7 +66,7 @@ const doc.body.append(hcont); -class MessageUserStore { +export const MessageUserStore = new class { constructor() { this.staticMessage = new MessageModel(); @@ -128,7 +128,7 @@ class MessageUserStore { ); this.messageListPageCount = ko.computed(() => { - const page = Math.ceil(this.messageListCount() / SettingsStore.messagesPerPage()); + const page = Math.ceil(this.messageListCount() / SettingsUserStore.messagesPerPage()); return 0 >= page ? 1 : page; }); @@ -136,7 +136,7 @@ class MessageUserStore { read: this.messageListSearch, write: (value) => { rl.route.setHash( - mailBox(FolderStore.currentFolderFullNameHash(), 1, value.toString().trim(), this.messageListThreadUid()) + mailBox(FolderUserStore.currentFolderFullNameHash(), 1, value.toString().trim(), this.messageListThreadUid()) ); } }); @@ -226,11 +226,11 @@ class MessageUserStore { this.message.subscribe(message => { if (message) { - if (!SettingsStore.usePreviewPane()) { - AppStore.focusedState(Focused.MessageView); + if (!SettingsUserStore.usePreviewPane()) { + AppUserStore.focusedState(Focused.MessageView); } } else { - AppStore.focusedState(Focused.MessageList); + AppUserStore.focusedState(Focused.MessageList); this.messageFullScreenMode(false); this.hideMessageBodies(); @@ -262,12 +262,12 @@ class MessageUserStore { if (Array.isNotEmpty(newMessages)) { newMessages.forEach(item => addNewMessageCache(folder, item.Uid)); - NotificationStore.playSoundNotification(); + NotificationUserStore.playSoundNotification(); const len = newMessages.length; if (3 < len) { - NotificationStore.displayDesktopNotification( - AccountStore.email(), + NotificationUserStore.displayDesktopNotification( + AccountUserStore.email(), i18n('MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION', { 'COUNT': len }), @@ -275,7 +275,7 @@ class MessageUserStore { ); } else { newMessages.forEach(item => { - NotificationStore.displayDesktopNotification( + NotificationUserStore.displayDesktopNotification( EmailCollectionModel.reviveFromJson(item.From).toString(), item.Subject, { 'Folder': item.Folder, 'Uid': item.Uid } @@ -306,11 +306,11 @@ class MessageUserStore { messageList = this.messageList, currentMessage = this.message(); - const trashFolder = FolderStore.trashFolder(), - spamFolder = FolderStore.spamFolder(), + const trashFolder = FolderUserStore.trashFolder(), + spamFolder = FolderUserStore.spamFolder(), fromFolder = getFolderFromCacheList(fromFolderFullNameRaw), toFolder = toFolderFullNameRaw ? getFolderFromCacheList(toFolderFullNameRaw) : null, - currentFolderFullNameRaw = FolderStore.currentFolderFullNameRaw(), + currentFolderFullNameRaw = FolderUserStore.currentFolderFullNameRaw(), messages = currentFolderFullNameRaw === fromFolderFullNameRaw ? messageList.filter(item => item && uidForRemove.includes(pInt(item.uid))) @@ -391,7 +391,7 @@ class MessageUserStore { rl.route.setHash( mailBox( - FolderStore.currentFolderFullNameHash(), + FolderUserStore.currentFolderFullNameHash(), this.messageListPage(), this.messageListSearch(), this.messageListThreadUid() @@ -405,7 +405,7 @@ class MessageUserStore { rl.route.setHash( mailBox( - FolderStore.currentFolderFullNameHash(), + FolderUserStore.currentFolderFullNameHash(), this.messageListPage(), this.messageListSearch(), this.messageListThreadUid() @@ -418,7 +418,7 @@ class MessageUserStore { rl.route.setHash( mailBox( - FolderStore.currentFolderFullNameHash(), + FolderUserStore.currentFolderFullNameHash(), this.messageListPageBeforeThread(), this.messageListSearch() ), @@ -454,7 +454,7 @@ class MessageUserStore { */ initOpenPgpControls(messageTextBody, message) { messageTextBody && messageTextBody.querySelectorAll('.b-plain-openpgp:not(.inited)').forEach(node => - PgpStore.initMessageBodyControls(node, message) + PgpUserStore.initMessageBodyControls(node, message) ); } @@ -517,13 +517,13 @@ class MessageUserStore { let isHtml = !!json.Html; if (isHtml) { resultHtml = json.Html.toString(); - if (SettingsStore.removeColors()) { + if (SettingsUserStore.removeColors()) { resultHtml = removeColors(resultHtml); } } else if (json.Plain) { resultHtml = plainToHtml(json.Plain.toString()); - if ((message.isPgpSigned() || message.isPgpEncrypted()) && PgpStore.capaOpenPGP()) { + if ((message.isPgpSigned() || message.isPgpEncrypted()) && PgpUserStore.capaOpenPGP()) { plain = pString(json.Plain); const isPgpEncrypted = /---BEGIN PGP MESSAGE---/.test(plain); @@ -578,7 +578,7 @@ class MessageUserStore { message.showInternalImages(); } - if (message.hasImages() && SettingsStore.showImages()) { + if (message.hasImages() && SettingsUserStore.showImages()) { message.showExternalImages(); } @@ -725,7 +725,7 @@ class MessageUserStore { this.messageListCount(iCount); this.messageListSearch(pString(collection.Search)); - this.messageListPage(Math.ceil(iOffset / SettingsStore.messagesPerPage() + 1)); + this.messageListPage(Math.ceil(iOffset / SettingsUserStore.messagesPerPage() + 1)); this.messageListThreadUid(pString(data.Result.ThreadUid)); this.messageListEndFolder(collection.Folder); @@ -740,7 +740,7 @@ class MessageUserStore { clearNewMessageCache(); - if (folder && (cached || unreadCountChange || SettingsStore.useThreads())) { + if (folder && (cached || unreadCountChange || SettingsUserStore.useThreads())) { rl.app.folderInformation(folder.fullNameRaw, collection); } } else { @@ -749,6 +749,4 @@ class MessageUserStore { this.messageListError(getNotification(data && data.ErrorCode ? data.ErrorCode : Notification.CantGetMessageList)); } } -} - -export default new MessageUserStore(); +}; diff --git a/dev/Stores/User/Notification.js b/dev/Stores/User/Notification.js index e60939bd8..a5b72e482 100644 --- a/dev/Stores/User/Notification.js +++ b/dev/Stores/User/Notification.js @@ -1,6 +1,6 @@ import ko from 'ko'; -import Audio from 'Common/Audio'; +import { SMAudio } from 'Common/Audio'; import { SettingsGet } from 'Common/Globals'; import * as Links from 'Common/Links'; @@ -35,7 +35,7 @@ if (WorkerNotifications && ServiceWorkerRegistration && ServiceWorkerRegistratio console.log('ServiceWorker Notifications not supported'); } -class NotificationUserStore { +export const NotificationUserStore = new class { constructor() { this.enableSoundNotification = ko.observable(false); @@ -58,7 +58,7 @@ class NotificationUserStore { */ playSoundNotification(skipSetting) { if (skipSetting ? true : this.enableSoundNotification()) { - Audio.playNotification(); + SMAudio.playNotification(); } } @@ -106,6 +106,4 @@ class NotificationUserStore { this.enableSoundNotification(!!SettingsGet('SoundNotification')); this.enableDesktopNotification(!!SettingsGet('DesktopNotifications')); } -} - -export default new NotificationUserStore(); +}; diff --git a/dev/Stores/User/Pgp.js b/dev/Stores/User/Pgp.js index 3e839333d..c64547754 100644 --- a/dev/Stores/User/Pgp.js +++ b/dev/Stores/User/Pgp.js @@ -4,7 +4,7 @@ import { i18n } from 'Common/Translator'; import { pString } from 'Common/Utils'; import { doc } from 'Common/Globals'; -import AccountStore from 'Stores/User/Account'; +import { AccountUserStore } from 'Stores/User/Account'; import { showScreenPopup } from 'Knoin/Knoin'; @@ -132,7 +132,7 @@ function domControlSignedClickHelper(store, dom, armoredMessage) { }; } -class PgpUserStore { +export const PgpUserStore = new class { constructor() { this.capaOpenPGP = ko.observable(false); @@ -260,7 +260,7 @@ class PgpUserStore { * @returns {?} */ findSelfPrivateKey(password) { - return this.findPrivateKeyByEmail(AccountStore.email(), password); + return this.findPrivateKeyByEmail(AccountUserStore.email(), password); } decryptMessage(message, recipients, fCallback) { @@ -365,6 +365,4 @@ class PgpUserStore { } } } -} - -export default new PgpUserStore(); +}; diff --git a/dev/Stores/User/Quota.js b/dev/Stores/User/Quota.js index 3066986d7..c5ba326ce 100644 --- a/dev/Stores/User/Quota.js +++ b/dev/Stores/User/Quota.js @@ -1,6 +1,6 @@ import ko from 'ko'; -class QuotaUserStore { +export const QuotaUserStore = new class { constructor() { this.quota = ko.observable(0); this.usage = ko.observable(0); @@ -21,6 +21,4 @@ class QuotaUserStore { this.quota(quota * 1024); this.usage(usage * 1024); } -} - -export default new QuotaUserStore(); +}; diff --git a/dev/Stores/User/Settings.js b/dev/Stores/User/Settings.js index 8eae70437..7908e9f7e 100644 --- a/dev/Stores/User/Settings.js +++ b/dev/Stores/User/Settings.js @@ -6,7 +6,7 @@ import { pInt } from 'Common/Utils'; import { $htmlCL, SettingsGet } from 'Common/Globals'; import { ThemeStore } from 'Stores/Theme'; -class SettingsUserStore { +export const SettingsUserStore = new class { constructor() { this.layout = ko .observable(Layout.SidePreview) @@ -36,7 +36,12 @@ class SettingsUserStore { this.usePreviewPane = ko.computed(() => Layout.NoPreview !== this.layout() && !ThemeStore.isMobile()); - this.subscribers(); + this.layout.subscribe(value => { + $htmlCL.toggle('rl-no-preview-pane', Layout.NoPreview === value); + $htmlCL.toggle('rl-side-preview-pane', Layout.SidePreview === value); + $htmlCL.toggle('rl-bottom-preview-pane', Layout.BottomPreview === value); + dispatchEvent(new CustomEvent('rl-layout', {detail:value})); + }); let iAutoLogoutTimer; this.delayLogout = (() => { @@ -50,15 +55,6 @@ class SettingsUserStore { }).throttle(5000); } - subscribers() { - this.layout.subscribe(value => { - $htmlCL.toggle('rl-no-preview-pane', Layout.NoPreview === value); - $htmlCL.toggle('rl-side-preview-pane', Layout.SidePreview === value); - $htmlCL.toggle('rl-bottom-preview-pane', Layout.BottomPreview === value); - dispatchEvent(new CustomEvent('rl-layout', {detail:value})); - }); - } - populate() { this.layout(pInt(SettingsGet('Layout'))); this.editorDefaultType(SettingsGet('EditorDefaultType')); @@ -75,6 +71,4 @@ class SettingsUserStore { this.delayLogout(); } -} - -export default new SettingsUserStore(); +}; diff --git a/dev/Stores/User/Template.js b/dev/Stores/User/Template.js index c4151fe3d..112f2ee50 100644 --- a/dev/Stores/User/Template.js +++ b/dev/Stores/User/Template.js @@ -2,7 +2,7 @@ import ko from 'ko'; // import Remote from 'Remote/User/Fetch'; -class TemplateUserStore { +export const TemplateUserStore = new class { constructor() { this.templates = ko.observableArray(); this.templates.loading = ko.observable(false).extend({ debounce: 100 }); @@ -29,6 +29,4 @@ class TemplateUserStore { // } // }); } -} - -export default new TemplateUserStore(); +}; diff --git a/dev/View/Popup/AddOpenPgpKey.js b/dev/View/Popup/AddOpenPgpKey.js index a716959e9..1ed1b1238 100644 --- a/dev/View/Popup/AddOpenPgpKey.js +++ b/dev/View/Popup/AddOpenPgpKey.js @@ -1,4 +1,4 @@ -import PgpStore from 'Stores/User/Pgp'; +import { PgpUserStore } from 'Stores/User/Pgp'; import { decorateKoCommands } from 'Knoin/Knoin'; import { AbstractViewPopup } from 'Knoin/AbstractViews'; @@ -26,7 +26,7 @@ class AddOpenPgpKeyPopupView extends AbstractViewPopup { addOpenPgpKeyCommand() { // eslint-disable-next-line max-len const reg = /[-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[-]{3,6}[\s\S]+?[-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[-]{3,6}/gi, - openpgpKeyring = PgpStore.openpgpKeyring; + openpgpKeyring = PgpUserStore.openpgpKeyring; let keyTrimmed = this.key().trim(); diff --git a/dev/View/Popup/AdvancedSearch.js b/dev/View/Popup/AdvancedSearch.js index 7e275769f..26b1e617b 100644 --- a/dev/View/Popup/AdvancedSearch.js +++ b/dev/View/Popup/AdvancedSearch.js @@ -2,7 +2,7 @@ import ko from 'ko'; import { i18n, trigger as translatorTrigger } from 'Common/Translator'; -import MessageStore from 'Stores/User/Message'; +import { MessageUserStore } from 'Stores/User/Message'; import { decorateKoCommands } from 'Knoin/Knoin'; import { AbstractViewPopup } from 'Knoin/AbstractViews'; @@ -47,7 +47,7 @@ class AdvancedSearchPopupView extends AbstractViewPopup { searchCommand() { const search = this.buildSearchString(); if (search) { - MessageStore.mainMessageListSearch(search); + MessageUserStore.mainMessageListSearch(search); } this.cancelCommand(); diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index f55676a19..91bd352fc 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -24,13 +24,13 @@ import { timestampToString } from 'Common/Momentor'; import { MessageFlagsCache, setFolderHash } from 'Common/Cache'; import { Settings, SettingsGet } from 'Common/Globals'; -import AppStore from 'Stores/User/App'; -import SettingsStore from 'Stores/User/Settings'; +import { AppUserStore } from 'Stores/User/App'; +import { SettingsUserStore } from 'Stores/User/Settings'; import { IdentityUserStore } from 'Stores/User/Identity'; -import AccountStore from 'Stores/User/Account'; -import FolderStore from 'Stores/User/Folder'; -import PgpStore from 'Stores/User/Pgp'; -import MessageStore from 'Stores/User/Message'; +import { AccountUserStore } from 'Stores/User/Account'; +import { FolderUserStore } from 'Stores/User/Folder'; +import { PgpUserStore } from 'Stores/User/Pgp'; +import { MessageUserStore } from 'Stores/User/Message'; import Remote from 'Remote/User/Fetch'; @@ -126,13 +126,13 @@ class ComposePopupView extends AbstractViewPopup { this.sLastFocusedField = 'to'; - this.allowContacts = !!AppStore.contactsIsAllowed(); + this.allowContacts = !!AppUserStore.contactsIsAllowed(); this.bSkipNextHide = false; - this.composeInEdit = AppStore.composeInEdit; - this.editorDefaultType = SettingsStore.editorDefaultType; + this.composeInEdit = AppUserStore.composeInEdit; + this.editorDefaultType = SettingsUserStore.editorDefaultType; - this.capaOpenPGP = PgpStore.capaOpenPGP; + this.capaOpenPGP = PgpUserStore.capaOpenPGP; this.identities = IdentityUserStore; @@ -319,8 +319,8 @@ class ComposePopupView extends AbstractViewPopup { setInterval(() => { if ( this.modalVisibility() && - !FolderStore.draftFolderNotEnabled() && - SettingsStore.allowDraftAutosave() && + !FolderUserStore.draftFolderNotEnabled() && + SettingsUserStore.allowDraftAutosave() && !this.isEmptyForm(false) && !this.saving() && !this.sending() && @@ -365,7 +365,7 @@ class ComposePopupView extends AbstractViewPopup { } sendCommand() { - let sSentFolder = FolderStore.sentFolder(); + let sSentFolder = FolderUserStore.sentFolder(); this.attachmentsInProcessError(false); this.attachmentsInErrorError(false); @@ -384,7 +384,7 @@ class ComposePopupView extends AbstractViewPopup { } if (!this.emptyToError() && !this.attachmentsInErrorError() && !this.attachmentsInProcessError()) { - if (SettingsStore.replySameFolder()) { + if (SettingsUserStore.replySameFolder()) { if ( isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length && @@ -430,7 +430,7 @@ class ComposePopupView extends AbstractViewPopup { } saveCommand() { - if (FolderStore.draftFolderNotEnabled()) { + if (FolderUserStore.draftFolderNotEnabled()) { showScreenPopup(FolderSystemPopupView, [SetSystemFoldersNotification.Draft]); } else { this.savedError(false); @@ -438,11 +438,11 @@ class ComposePopupView extends AbstractViewPopup { this.autosaveStart(); - setFolderHash(FolderStore.draftFolder(), ''); + setFolderHash(FolderUserStore.draftFolder(), ''); Remote.saveMessage( this.saveMessageResponse.bind(this), - this.getMessageRequestParams(FolderStore.draftFolder()) + this.getMessageRequestParams(FolderUserStore.draftFolder()) ); } @@ -470,8 +470,8 @@ class ComposePopupView extends AbstractViewPopup { this.modalVisibility() && !this.saving() && !this.sending() && - !FolderStore.draftFolderNotEnabled() && - SettingsStore.allowDraftAutosave() + !FolderUserStore.draftFolderNotEnabled() && + SettingsUserStore.allowDraftAutosave() ) { this.saveCommand(); } @@ -491,8 +491,8 @@ class ComposePopupView extends AbstractViewPopup { autosaveFunction() { if ( this.modalVisibility() && - !FolderStore.draftFolderNotEnabled() && - SettingsStore.allowDraftAutosave() && + !FolderUserStore.draftFolderNotEnabled() && + SettingsUserStore.allowDraftAutosave() && !this.isEmptyForm(false) && !this.saving() && !this.sending() && @@ -518,7 +518,7 @@ class ComposePopupView extends AbstractViewPopup { } openOpenPgpPopup() { - if (PgpStore.capaOpenPGP() && this.oEditor && !this.oEditor.isHtml()) { + if (PgpUserStore.capaOpenPGP() && this.oEditor && !this.oEditor.isHtml()) { showScreenPopup(ComposeOpenPgpPopupView, [ result => this.editor(editor => editor.setPlain(result)), this.oEditor.getData(false), @@ -531,10 +531,10 @@ class ComposePopupView extends AbstractViewPopup { } reloadDraftFolder() { - const draftFolder = FolderStore.draftFolder(); + const draftFolder = FolderUserStore.draftFolder(); if (draftFolder && UNUSED_OPTION_VALUE !== draftFolder) { setFolderHash(draftFolder, ''); - if (FolderStore.currentFolderFullNameRaw() === draftFolder) { + if (FolderUserStore.currentFolderFullNameRaw() === draftFolder) { rl.app.reloadMessageList(true); } else { rl.app.folderInformation(draftFolder); @@ -627,9 +627,9 @@ class ComposePopupView extends AbstractViewPopup { result = true; if (this.bFromDraft) { - const message = MessageStore.message(); + const message = MessageUserStore.message(); if (message && this.draftFolder() === message.folder && this.draftUid() === message.uid) { - MessageStore.message(null); + MessageUserStore.message(null); } } @@ -656,7 +656,7 @@ class ComposePopupView extends AbstractViewPopup { this.autosaveStop(); if (!this.bSkipNextHide) { - AppStore.composeInEdit(false); + AppUserStore.composeInEdit(false); this.reset(); } @@ -738,7 +738,7 @@ class ComposePopupView extends AbstractViewPopup { this.autosaveStart(); - if (AppStore.composeInEdit()) { + if (AppUserStore.composeInEdit()) { type = type || ComposeType.Empty; if (ComposeType.Empty !== type) { showScreenPopup(AskPopupView, [ @@ -811,7 +811,7 @@ class ComposePopupView extends AbstractViewPopup { * @param {string=} sCustomPlainText = null */ initOnShow(sType, oMessageOrArray, aToEmails, aCcEmails, aBccEmails, sCustomSubject, sCustomPlainText) { - AppStore.composeInEdit(true); + AppUserStore.composeInEdit(true); let sFrom = '', sTo = '', @@ -825,7 +825,7 @@ class ComposePopupView extends AbstractViewPopup { message = null; const excludeEmail = {}, - mEmail = AccountStore.email(), + mEmail = AccountUserStore.email(), lineComposeType = sType || ComposeType.Empty; oMessageOrArray = oMessageOrArray || null; diff --git a/dev/View/Popup/ComposeOpenPgp.js b/dev/View/Popup/ComposeOpenPgp.js index 68a9a27a3..870a0b51a 100644 --- a/dev/View/Popup/ComposeOpenPgp.js +++ b/dev/View/Popup/ComposeOpenPgp.js @@ -5,7 +5,7 @@ import { pString, defaultOptionsAfterRender } from 'Common/Utils'; import { KeyState } from 'Common/Enums'; import { i18n } from 'Common/Translator'; -import PgpStore from 'Stores/User/Pgp'; +import { PgpUserStore } from 'Stores/User/Pgp'; import { EmailModel } from 'Model/Email'; @@ -44,7 +44,7 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup { encryptKeysView: () => this.encryptKeys.map(oKey => (oKey ? oKey.key : null)).filter(v => v), privateKeysOptions: () => { - const opts = PgpStore.openpgpkeysPrivate().map(oKey => { + const opts = PgpUserStore.openpgpkeysPrivate().map(oKey => { if (this.signKey() && this.signKey().key.id === oKey.id) { return null; } @@ -59,7 +59,7 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup { }, publicKeysOptions: () => { - const opts = PgpStore.openpgpkeysPublic().map(oKey => { + const opts = PgpUserStore.openpgpkeysPublic().map(oKey => { if (this.encryptKeysView().includes(oKey)) { return null; } @@ -176,19 +176,19 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup { try { if (aPublicKeys.length) { if (privateKey) { - pgpPromise = PgpStore.openpgp.encrypt({ + pgpPromise = PgpUserStore.openpgp.encrypt({ data: this.text(), publicKeys: aPublicKeys, privateKeys: [privateKey] }); } else { - pgpPromise = PgpStore.openpgp.encrypt({ + pgpPromise = PgpUserStore.openpgp.encrypt({ data: this.text(), publicKeys: aPublicKeys }); } } else if (privateKey) { - pgpPromise = PgpStore.openpgp.sign({ + pgpPromise = PgpUserStore.openpgp.sign({ data: this.text(), privateKeys: [privateKey] }); @@ -342,7 +342,7 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup { emailLine = identity.email(); rec.unshift(emailLine); - const keys = PgpStore.findAllPrivateKeysByEmailNotNative(emailLine); + const keys = PgpUserStore.findAllPrivateKeysByEmailNotNative(emailLine); if (keys && keys[0]) { this.signKey({ 'users': keys[0].users || [emailLine], @@ -359,7 +359,7 @@ class ComposeOpenPgpPopupView extends AbstractViewPopup { if (rec.length) { this.encryptKeys( rec.map(recEmail => { - const keys = PgpStore.findAllPublicKeysByEmailNotNative(recEmail); + const keys = PgpUserStore.findAllPublicKeysByEmailNotNative(recEmail); return keys ? keys.map(publicKey => ({ 'empty': !publicKey, diff --git a/dev/View/Popup/Contacts.js b/dev/View/Popup/Contacts.js index eb022854b..69b8a32fd 100644 --- a/dev/View/Popup/Contacts.js +++ b/dev/View/Popup/Contacts.js @@ -16,8 +16,8 @@ import { Selector } from 'Common/Selector'; import { serverRequestRaw, serverRequest } from 'Common/Links'; import { i18n, getNotification } from 'Common/Translator'; -import SettingsStore from 'Stores/User/Settings'; -import ContactStore from 'Stores/User/Contact'; +import { SettingsUserStore } from 'Stores/User/Settings'; +import { ContactUserStore } from 'Stores/User/Contact'; import Remote from 'Remote/User/Fetch'; @@ -39,8 +39,8 @@ class ContactsPopupView extends AbstractViewPopup { this.bBackToCompose = false; this.sLastComposeFocusedField = ''; - this.allowContactsSync = ContactStore.allowContactsSync; - this.enableContactsSync = ContactStore.enableContactsSync; + this.allowContactsSync = ContactUserStore.allowSync; + this.enableContactsSync = ContactUserStore.enableSync; this.addObservables({ search: '', @@ -66,14 +66,14 @@ class ContactsPopupView extends AbstractViewPopup { watchHash: false }); - this.contacts = ContactStore.contacts; + this.contacts = ContactUserStore; this.viewProperties = ko.observableArray(); - this.useCheckboxesInList = SettingsStore.useCheckboxesInList; + this.useCheckboxesInList = SettingsUserStore.useCheckboxesInList; this.selector = new Selector( - this.contacts, + ContactUserStore, this.currentContact, null, '.e-contact-item .actionHandle', @@ -119,7 +119,7 @@ class ContactsPopupView extends AbstractViewPopup { contactHasValidName: () => !!this.viewProperties.find(prop => propertyIsName(prop) && prop.isValid()), contactsCheckedOrSelected: () => { - const checked = this.contacts.filter(item => item.checked && item.checked()), + const checked = ContactUserStore.filter(item => item.checked && item.checked()), selected = this.currentContact(); return selected @@ -347,9 +347,9 @@ class ContactsPopupView extends AbstractViewPopup { if (j) { j.on('onStart', () => { - this.contacts.importing(true); + ContactUserStore.importing(true); }).on('onComplete', (id, result, data) => { - this.contacts.importing(false); + ContactUserStore.importing(false); this.reloadContactList(); if (!id || !result || !data || !data.Result) { alert(i18n('CONTACTS/ERROR_IMPORT_FILE')); @@ -360,11 +360,10 @@ class ContactsPopupView extends AbstractViewPopup { } removeCheckedOrSelectedContactsFromList() { - const koContacts = this.contacts, - contacts = this.contactsCheckedOrSelected(); + const contacts = this.contactsCheckedOrSelected(); let currentContact = this.currentContact(), - count = this.contacts.length; + count = ContactUserStore.length; if (contacts.length) { contacts.forEach(contact => { @@ -383,7 +382,7 @@ class ContactsPopupView extends AbstractViewPopup { setTimeout(() => { contacts.forEach(contact => { - koContacts.remove(contact); + ContactUserStore.remove(contact); delegateRunOnDestroy(contact); }); }, 500); @@ -459,7 +458,7 @@ class ContactsPopupView extends AbstractViewPopup { offset = 0; } - this.contacts.loading(true); + ContactUserStore.loading(true); Remote.contacts( (result, data) => { let count = 0, @@ -479,10 +478,10 @@ class ContactsPopupView extends AbstractViewPopup { this.contactsCount(count); - delegateRunOnDestroy(this.contacts()); - this.contacts(list); + delegateRunOnDestroy(ContactUserStore()); + ContactUserStore(list); - this.contacts.loading(false); + ContactUserStore.loading(false); this.viewClearSearch(!!this.search()); }, offset, @@ -533,8 +532,8 @@ class ContactsPopupView extends AbstractViewPopup { this.search(''); this.contactsCount(0); - delegateRunOnDestroy(this.contacts()); - this.contacts([]); + delegateRunOnDestroy(ContactUserStore()); + ContactUserStore([]); this.sLastComposeFocusedField = ''; diff --git a/dev/View/Popup/Filter.js b/dev/View/Popup/Filter.js index 75e4dc135..d22d0d470 100644 --- a/dev/View/Popup/Filter.js +++ b/dev/View/Popup/Filter.js @@ -5,7 +5,7 @@ import { FilterConditionField, FilterConditionType } from 'Model/FilterCondition import { defaultOptionsAfterRender } from 'Common/Utils'; import { i18n, initOnStartOrLangChange } from 'Common/Translator'; -import FolderStore from 'Stores/User/Folder'; +import { FolderUserStore } from 'Stores/User/Folder'; import { SieveUserStore } from 'Stores/User/Sieve'; import { decorateKoCommands } from 'Knoin/Knoin'; @@ -25,7 +25,7 @@ class FilterPopupView extends AbstractViewPopup { this.fTrueCallback = null; this.defaultOptionsAfterRender = defaultOptionsAfterRender; - this.folderSelectList = FolderStore.folderMenuForFilters; + this.folderSelectList = FolderUserStore.folderMenuForFilters; this.selectedFolderValue.subscribe(() => this.filter() && this.filter().actionValueError(false)); diff --git a/dev/View/Popup/FolderClear.js b/dev/View/Popup/FolderClear.js index cc30c6521..c2a82c465 100644 --- a/dev/View/Popup/FolderClear.js +++ b/dev/View/Popup/FolderClear.js @@ -2,7 +2,7 @@ import { StorageResultType, Notification } from 'Common/Enums'; import { i18n, getNotification } from 'Common/Translator'; import { setFolderHash } from 'Common/Cache'; -import MessageStore from 'Stores/User/Message'; +import { MessageUserStore } from 'Stores/User/Message'; import Remote from 'Remote/User/Fetch'; @@ -44,8 +44,8 @@ class FolderClearPopupView extends AbstractViewPopup { clearCommand() { const folderToClear = this.selectedFolder(); if (folderToClear) { - MessageStore.message(null); - MessageStore.messageList([]); + MessageUserStore.message(null); + MessageUserStore.messageList([]); this.clearingProcess(true); diff --git a/dev/View/Popup/FolderCreate.js b/dev/View/Popup/FolderCreate.js index ce8297d92..bef43e523 100644 --- a/dev/View/Popup/FolderCreate.js +++ b/dev/View/Popup/FolderCreate.js @@ -5,7 +5,7 @@ import { UNUSED_OPTION_VALUE } from 'Common/Consts'; import { defaultOptionsAfterRender } from 'Common/Utils'; import { folderListOptionsBuilder } from 'Common/UtilsUser'; -import FolderStore from 'Stores/User/Folder'; +import { FolderUserStore } from 'Stores/User/Folder'; import Remote from 'Remote/User/Fetch'; @@ -25,17 +25,15 @@ class FolderCreatePopupView extends AbstractViewPopup { this.parentFolderSelectList = ko.computed(() => { const top = [], - list = FolderStore.folderList(), - fRenameCallback = (oItem) => + list = FolderUserStore.folderList(), + fDisableCallback = FolderUserStore.namespace + ? item => FolderUserStore.namespace !== item.fullNameRaw.substr(0, FolderUserStore.namespace.length) + : null, + fRenameCallback = oItem => oItem ? (oItem.isSystemFolder() ? oItem.name() + ' ' + oItem.manageFolderSystemName() : oItem.name()) : ''; top.push(['', '']); - let fDisableCallback = null; - if (FolderStore.namespace) { - fDisableCallback = (item) => FolderStore.namespace !== item.fullNameRaw.substr(0, FolderStore.namespace.length); - } - return folderListOptionsBuilder([], list, [], top, null, fDisableCallback, null, fRenameCallback); }); @@ -48,8 +46,8 @@ class FolderCreatePopupView extends AbstractViewPopup { createFolderCommand() { let parentFolderName = this.selectedParentValue(); - if (!parentFolderName && 1 < FolderStore.namespace.length) { - parentFolderName = FolderStore.namespace.substr(0, FolderStore.namespace.length - 1); + if (!parentFolderName && 1 < FolderUserStore.namespace.length) { + parentFolderName = FolderUserStore.namespace.substr(0, FolderUserStore.namespace.length - 1); } rl.app.foldersPromisesActionHelper( diff --git a/dev/View/Popup/FolderSystem.js b/dev/View/Popup/FolderSystem.js index d2640a807..c5244a952 100644 --- a/dev/View/Popup/FolderSystem.js +++ b/dev/View/Popup/FolderSystem.js @@ -7,7 +7,7 @@ import { defaultOptionsAfterRender } from 'Common/Utils'; import { folderListOptionsBuilder } from 'Common/UtilsUser'; import { initOnStartOrLangChange, i18n } from 'Common/Translator'; -import FolderStore from 'Stores/User/Folder'; +import { FolderUserStore } from 'Stores/User/Folder'; import Remote from 'Remote/User/Fetch'; @@ -30,8 +30,8 @@ class FolderSystemPopupView extends AbstractViewPopup { this.folderSelectList = ko.computed(() => folderListOptionsBuilder( [], - FolderStore.folderList(), - FolderStore.folderListSystemNames(), + FolderUserStore.folderList(), + FolderUserStore.folderListSystemNames(), [ ['', this.sChooseOnText], [UNUSED_OPTION_VALUE, this.sUnuseText] @@ -45,28 +45,28 @@ class FolderSystemPopupView extends AbstractViewPopup { ) ); - this.sentFolder = FolderStore.sentFolder; - this.draftFolder = FolderStore.draftFolder; - this.spamFolder = FolderStore.spamFolder; - this.trashFolder = FolderStore.trashFolder; - this.archiveFolder = FolderStore.archiveFolder; + this.sentFolder = FolderUserStore.sentFolder; + this.draftFolder = FolderUserStore.draftFolder; + this.spamFolder = FolderUserStore.spamFolder; + this.trashFolder = FolderUserStore.trashFolder; + this.archiveFolder = FolderUserStore.archiveFolder; const settingsSet = Settings.set, fSetSystemFolders = () => { - settingsSet('SentFolder', FolderStore.sentFolder()); - settingsSet('DraftFolder', FolderStore.draftFolder()); - settingsSet('SpamFolder', FolderStore.spamFolder()); - settingsSet('TrashFolder', FolderStore.trashFolder()); - settingsSet('ArchiveFolder', FolderStore.archiveFolder()); + settingsSet('SentFolder', FolderUserStore.sentFolder()); + settingsSet('DraftFolder', FolderUserStore.draftFolder()); + settingsSet('SpamFolder', FolderUserStore.spamFolder()); + settingsSet('TrashFolder', FolderUserStore.trashFolder()); + settingsSet('ArchiveFolder', FolderUserStore.archiveFolder()); }, fSaveSystemFolders = (()=>{ fSetSystemFolders(); Remote.saveSystemFolders(()=>{}, { - SentFolder: FolderStore.sentFolder(), - DraftFolder: FolderStore.draftFolder(), - SpamFolder: FolderStore.spamFolder(), - TrashFolder: FolderStore.trashFolder(), - ArchiveFolder: FolderStore.archiveFolder(), + SentFolder: FolderUserStore.sentFolder(), + DraftFolder: FolderUserStore.draftFolder(), + SpamFolder: FolderUserStore.spamFolder(), + TrashFolder: FolderUserStore.trashFolder(), + ArchiveFolder: FolderUserStore.archiveFolder(), NullFolder: 'NullFolder' }); }).debounce(1000), @@ -75,7 +75,7 @@ class FolderSystemPopupView extends AbstractViewPopup { fSaveSystemFolders(); }; - ko.addSubscribablesTo(FolderStore, { + ko.addSubscribablesTo(FolderUserStore, { sentFolder: fCallback, draftFolder: fCallback, spamFolder: fCallback, diff --git a/dev/View/Popup/NewOpenPgpKey.js b/dev/View/Popup/NewOpenPgpKey.js index 84b204c2a..dfed2e1db 100644 --- a/dev/View/Popup/NewOpenPgpKey.js +++ b/dev/View/Popup/NewOpenPgpKey.js @@ -1,6 +1,6 @@ import { pInt } from 'Common/Utils'; -import PgpStore from 'Stores/User/Pgp'; +import { PgpUserStore } from 'Stores/User/Pgp'; import { decorateKoCommands } from 'Knoin/Knoin'; import { AbstractViewPopup } from 'Knoin/AbstractViews'; @@ -31,7 +31,7 @@ class NewOpenPgpKeyPopupView extends AbstractViewPopup { generateOpenPgpKeyCommand() { const userId = {}, - openpgpKeyring = PgpStore.openpgpKeyring; + openpgpKeyring = PgpUserStore.openpgpKeyring; this.emailError(!this.email().trim()); if (!openpgpKeyring || this.emailError()) { @@ -48,7 +48,7 @@ class NewOpenPgpKeyPopupView extends AbstractViewPopup { setTimeout(() => { try { - PgpStore.openpgp + PgpUserStore.openpgp .generateKey({ userIds: [userId], numBits: pInt(this.keyBitLength()), diff --git a/dev/View/User/AbstractSystemDropDown.js b/dev/View/User/AbstractSystemDropDown.js index 777e4c1ea..8021ab115 100644 --- a/dev/View/User/AbstractSystemDropDown.js +++ b/dev/View/User/AbstractSystemDropDown.js @@ -1,6 +1,6 @@ -import AppStore from 'Stores/User/App'; -import AccountStore from 'Stores/User/Account'; -import MessageStore from 'Stores/User/Message'; +import { AppUserStore } from 'Stores/User/App'; +import { AccountUserStore } from 'Stores/User/Account'; +import { MessageUserStore } from 'Stores/User/Message'; import { Capa, KeyState } from 'Common/Enums'; import { settings } from 'Common/Links'; @@ -23,24 +23,25 @@ export class AbstractSystemDropDownUserView extends AbstractViewRight { this.allowSettings = Settings.capa(Capa.Settings); this.allowHelp = Settings.capa(Capa.Help); - this.currentAudio = AppStore.currentAudio; + this.currentAudio = AppUserStore.currentAudio; - this.accountEmail = AccountStore.email; + this.accountEmail = AccountUserStore.email; - this.accounts = AccountStore.accounts; - this.accountsUnreadCount = AccountStore.accountsUnreadCount; + this.accounts = AccountUserStore.accounts; + this.accountsLoading = AccountUserStore.loading; + this.accountsUnreadCount = AccountUserStore.accountsUnreadCount; this.addObservables({ accountMenuDropdownTrigger: false, capaAdditionalAccounts: Settings.capa(Capa.AdditionalAccounts) }); - this.allowContacts = !!AppStore.contactsIsAllowed(); + this.allowContacts = !!AppUserStore.contactsIsAllowed(); this.addAccountClick = this.addAccountClick.bind(this); - addEventListener('audio.stop', () => AppStore.currentAudio('')); - addEventListener('audio.start', e => AppStore.currentAudio(e.detail)); + addEventListener('audio.stop', () => AppUserStore.currentAudio('')); + addEventListener('audio.start', e => AppUserStore.currentAudio(e.detail)); } stopPlay() { @@ -49,15 +50,15 @@ export class AbstractSystemDropDownUserView extends AbstractViewRight { accountClick(account, event) { if (account && 0 === event.button) { - AccountStore.accounts.loading(true); - setTimeout(() => AccountStore.accounts.loading(false), 1000); + AccountUserStore.loading(true); + setTimeout(() => AccountUserStore.loading(false), 1000); } return true; } emailTitle() { - return AccountStore.email(); + return AccountUserStore.email(); } settingsClick() { @@ -107,7 +108,7 @@ export class AbstractSystemDropDownUserView extends AbstractViewRight { onBuild() { shortcuts.add('m,contextmenu', '', [KeyState.MessageList, KeyState.MessageView, KeyState.Settings], () => { if (this.viewModelVisible) { - MessageStore.messageFullScreenMode(false); + MessageUserStore.messageFullScreenMode(false); this.accountMenuDropdownTrigger(true); return false; } diff --git a/dev/View/User/Login.js b/dev/View/User/Login.js index 144300b21..b67583552 100644 --- a/dev/View/User/Login.js +++ b/dev/View/User/Login.js @@ -9,7 +9,7 @@ import { ClientSideKeyName } from 'Common/EnumsUser'; import { getNotification, getNotificationFromResponse, reload as translatorReload, convertLangName } from 'Common/Translator'; -import AppStore from 'Stores/User/App'; +import { AppUserStore } from 'Stores/User/App'; import { LanguageStore } from 'Stores/Language'; import * as Local from 'Storage/Client'; @@ -233,8 +233,8 @@ class LoginUserView extends AbstractViewCenter { break; } - this.email(AppStore.devEmail); - this.password(AppStore.devPassword); + this.email(AppUserStore.devEmail); + this.password(AppUserStore.devPassword); setTimeout(() => { LanguageStore.language.subscribe((value) => { diff --git a/dev/View/User/MailBox/FolderList.js b/dev/View/User/MailBox/FolderList.js index 70801d055..a097a5fef 100644 --- a/dev/View/User/MailBox/FolderList.js +++ b/dev/View/User/MailBox/FolderList.js @@ -6,10 +6,10 @@ import { leftPanelDisabled, moveAction, Settings } from 'Common/Globals'; import { mailBox, settings } from 'Common/Links'; import { setFolderHash } from 'Common/Cache'; -import AppStore from 'Stores/User/App'; -import SettingsStore from 'Stores/User/Settings'; -import FolderStore from 'Stores/User/Folder'; -import MessageStore from 'Stores/User/Message'; +import { AppUserStore } from 'Stores/User/App'; +import { SettingsUserStore } from 'Stores/User/Settings'; +import { FolderUserStore } from 'Stores/User/Folder'; +import { MessageUserStore } from 'Stores/User/Message'; import { ThemeStore } from 'Stores/Theme'; import { showScreenPopup } from 'Knoin/Knoin'; @@ -25,29 +25,29 @@ export class FolderListMailBoxUserView extends AbstractViewLeft { this.oContentScrollable = null; - this.composeInEdit = AppStore.composeInEdit; + this.composeInEdit = AppUserStore.composeInEdit; - this.messageList = MessageStore.messageList; - this.folderList = FolderStore.folderList; - this.folderListSystem = FolderStore.folderListSystem; - this.foldersChanging = FolderStore.foldersChanging; + this.messageList = MessageUserStore.messageList; + this.folderList = FolderUserStore.folderList; + this.folderListSystem = FolderUserStore.folderListSystem; + this.foldersChanging = FolderUserStore.foldersChanging; this.moveAction = moveAction; - this.foldersListWithSingleInboxRootFolder = FolderStore.foldersListWithSingleInboxRootFolder; + this.foldersListWithSingleInboxRootFolder = FolderUserStore.foldersListWithSingleInboxRootFolder; this.leftPanelDisabled = leftPanelDisabled; this.allowComposer = Settings.capa(Capa.Composer); - this.allowContacts = !!AppStore.contactsIsAllowed(); + this.allowContacts = !!AppUserStore.contactsIsAllowed(); - this.folderListFocused = ko.computed(() => Focused.FolderList === AppStore.focusedState()); + this.folderListFocused = ko.computed(() => Focused.FolderList === AppUserStore.focusedState()); this.isInboxStarred = ko.computed( () => - FolderStore.currentFolder() && - FolderStore.currentFolder().isInbox() && - MessageStore.messageListSearch().trim().includes('is:flagged') + FolderUserStore.currentFolder() && + FolderUserStore.currentFolder().isInbox() && + MessageUserStore.messageListSearch().trim().includes('is:flagged') ); } @@ -69,17 +69,17 @@ export class FolderListMailBoxUserView extends AbstractViewLeft { if (isMove) { moveAction(false); rl.app.moveMessagesToFolder( - FolderStore.currentFolderFullNameRaw(), - MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), + FolderUserStore.currentFolderFullNameRaw(), + MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails(), folder.fullNameRaw, event.ctrlKey ); } else { - if (!SettingsStore.usePreviewPane()) { - MessageStore.message(null); + if (!SettingsUserStore.usePreviewPane()) { + MessageUserStore.message(null); } - if (folder.fullNameRaw === FolderStore.currentFolderFullNameRaw()) { + if (folder.fullNameRaw === FolderUserStore.currentFolderFullNameRaw()) { setFolderHash(folder.fullNameRaw, ''); } @@ -89,7 +89,7 @@ export class FolderListMailBoxUserView extends AbstractViewLeft { ); } - AppStore.focusedState(Focused.MessageList); + AppUserStore.focusedState(Focused.MessageList); } }; @@ -144,7 +144,7 @@ export class FolderListMailBoxUserView extends AbstractViewLeft { shortcuts.add('enter,open', '', KeyState.FolderList, () => { const item = qs('.b-folders .e-item .e-link:not(.hidden).focused'); if (item) { - AppStore.focusedState(Focused.MessageList); + AppUserStore.focusedState(Focused.MessageList); item.click(); } @@ -165,12 +165,12 @@ export class FolderListMailBoxUserView extends AbstractViewLeft { // shortcuts.add('tab', 'shift', KeyState.FolderList, () => { shortcuts.add('escape,tab,arrowright', '', KeyState.FolderList, () => { - AppStore.focusedState(Focused.MessageList); + AppUserStore.focusedState(Focused.MessageList); moveAction(false); return false; }); - AppStore.focusedState.subscribe(value => { + AppUserStore.focusedState.subscribe(value => { let el = qs('.b-folders .e-item .e-link.focused'); el && qs('.b-folders .e-item .e-link.focused').classList.remove('focused'); if (Focused.FolderList === value) { diff --git a/dev/View/User/MailBox/MessageList.js b/dev/View/User/MailBox/MessageList.js index 187ac839b..692e68b34 100644 --- a/dev/View/User/MailBox/MessageList.js +++ b/dev/View/User/MailBox/MessageList.js @@ -32,11 +32,11 @@ import { addRequestedMessage } from 'Common/Cache'; -import AppStore from 'Stores/User/App'; -import QuotaStore from 'Stores/User/Quota'; -import SettingsStore from 'Stores/User/Settings'; -import FolderStore from 'Stores/User/Folder'; -import MessageStore from 'Stores/User/Message'; +import { AppUserStore } from 'Stores/User/App'; +import { QuotaUserStore } from 'Stores/User/Quota'; +import { SettingsUserStore } from 'Stores/User/Settings'; +import { FolderUserStore } from 'Stores/User/Folder'; +import { MessageUserStore } from 'Stores/User/Message'; import { ThemeStore } from 'Stores/Theme'; import Remote from 'Remote/User/Fetch'; @@ -48,7 +48,7 @@ import { FolderClearPopupView } from 'View/Popup/FolderClear'; import { AdvancedSearchPopupView } from 'View/Popup/AdvancedSearch'; const - canBeMovedHelper = () => MessageStore.hasCheckedOrSelected(); + canBeMovedHelper = () => MessageUserStore.hasCheckedOrSelected(); export class MessageListMailBoxUserView extends AbstractViewRight { constructor() { @@ -71,39 +71,40 @@ export class MessageListMailBoxUserView extends AbstractViewRight { this.popupVisibility = popupVisibility; - this.message = MessageStore.message; - this.messageList = MessageStore.messageList; - this.messageListDisableAutoSelect = MessageStore.messageListDisableAutoSelect; + this.message = MessageUserStore.message; + this.messageList = MessageUserStore.messageList; + this.messageListDisableAutoSelect = MessageUserStore.messageListDisableAutoSelect; - this.folderList = FolderStore.folderList; + this.folderList = FolderUserStore.folderList; - this.composeInEdit = AppStore.composeInEdit; + this.composeInEdit = AppUserStore.composeInEdit; this.leftPanelDisabled = leftPanelDisabled; - this.selectorMessageSelected = MessageStore.selectorMessageSelected; - this.selectorMessageFocused = MessageStore.selectorMessageFocused; - this.isMessageSelected = MessageStore.isMessageSelected; - this.messageListSearch = MessageStore.messageListSearch; - this.messageListThreadUid = MessageStore.messageListThreadUid; - this.messageListError = MessageStore.messageListError; - this.folderMenuForMove = FolderStore.folderMenuForMove; + this.selectorMessageSelected = MessageUserStore.selectorMessageSelected; + this.selectorMessageFocused = MessageUserStore.selectorMessageFocused; + this.isMessageSelected = MessageUserStore.isMessageSelected; + this.messageListSearch = MessageUserStore.messageListSearch; + this.messageListThreadUid = MessageUserStore.messageListThreadUid; + this.messageListError = MessageUserStore.messageListError; + this.folderMenuForMove = FolderUserStore.folderMenuForMove; - this.useCheckboxesInList = SettingsStore.useCheckboxesInList; + this.useCheckboxesInList = SettingsUserStore.useCheckboxesInList; - this.mainMessageListSearch = MessageStore.mainMessageListSearch; - this.messageListEndFolder = MessageStore.messageListEndFolder; - this.messageListEndThreadUid = MessageStore.messageListEndThreadUid; + this.mainMessageListSearch = MessageUserStore.mainMessageListSearch; + this.messageListEndFolder = MessageUserStore.messageListEndFolder; + this.messageListEndThreadUid = MessageUserStore.messageListEndThreadUid; - this.messageListCheckedOrSelected = MessageStore.messageListCheckedOrSelected; - this.messageListCheckedOrSelectedUidsWithSubMails = MessageStore.messageListCheckedOrSelectedUidsWithSubMails; - this.messageListCompleteLoadingThrottle = MessageStore.messageListCompleteLoadingThrottle; - this.messageListCompleteLoadingThrottleForAnimation = MessageStore.messageListCompleteLoadingThrottleForAnimation; + this.messageListCheckedOrSelected = MessageUserStore.messageListCheckedOrSelected; + this.messageListCheckedOrSelectedUidsWithSubMails = MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails; + this.messageListCompleteLoadingThrottle = MessageUserStore.messageListCompleteLoadingThrottle; + this.messageListCompleteLoadingThrottleForAnimation = + MessageUserStore.messageListCompleteLoadingThrottleForAnimation; initOnStartOrLangChange(() => this.emptySubjectValue = i18n('MESSAGE_LIST/EMPTY_SUBJECT_TEXT')); - this.userQuota = QuotaStore.quota; - this.userUsageSize = QuotaStore.usage; - this.userUsageProc = QuotaStore.percentage; + this.userQuota = QuotaUserStore.quota; + this.userUsageSize = QuotaUserStore.usage; + this.userUsageProc = QuotaUserStore.percentage; this.addObservables({ moveDropdownTrigger: false, @@ -123,17 +124,18 @@ export class MessageListMailBoxUserView extends AbstractViewRight { this.addComputables({ messageListSearchDesc: () => { - const value = MessageStore.messageListEndSearch(); + const value = MessageUserStore.messageListEndSearch(); return value ? i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', { 'SEARCH': value }) : '' }, - messageListPaginator: computedPaginatorHelper(MessageStore.messageListPage, MessageStore.messageListPageCount), + messageListPaginator: computedPaginatorHelper(MessageUserStore.messageListPage, + MessageUserStore.messageListPageCount), checkAll: { - read: () => 0 < MessageStore.messageListChecked().length, + read: () => 0 < MessageUserStore.messageListChecked().length, write: (value) => { value = !!value; - MessageStore.messageList.forEach(message => message.checked(value)); + MessageUserStore.messageList.forEach(message => message.checked(value)); } }, @@ -143,25 +145,25 @@ export class MessageListMailBoxUserView extends AbstractViewRight { }, isIncompleteChecked: () => { - const c = MessageStore.messageListChecked().length; - return c && MessageStore.messageList.length > c; + const c = MessageUserStore.messageListChecked().length; + return c && MessageUserStore.messageList.length > c; }, hasMessages: () => 0 < this.messageList.length, - isSpamFolder: () => FolderStore.spamFolder() === this.messageListEndFolder() && FolderStore.spamFolder(), + isSpamFolder: () => (FolderUserStore.spamFolder() || 0) === this.messageListEndFolder(), - isSpamDisabled: () => UNUSED_OPTION_VALUE === FolderStore.spamFolder(), + isSpamDisabled: () => UNUSED_OPTION_VALUE === FolderUserStore.spamFolder(), - isTrashFolder: () => FolderStore.trashFolder() === this.messageListEndFolder() && FolderStore.trashFolder(), + isTrashFolder: () => (FolderUserStore.trashFolder() || 0) === this.messageListEndFolder(), - isDraftFolder: () => FolderStore.draftFolder() === this.messageListEndFolder() && FolderStore.draftFolder(), + isDraftFolder: () => (FolderUserStore.draftFolder() || 0) === this.messageListEndFolder(), - isSentFolder: () => FolderStore.sentFolder() === this.messageListEndFolder() && FolderStore.sentFolder(), + isSentFolder: () => (FolderUserStore.sentFolder() || 0) === this.messageListEndFolder(), - isArchiveFolder: () => FolderStore.archiveFolder() === this.messageListEndFolder() && FolderStore.archiveFolder(), + isArchiveFolder: () => (FolderUserStore.archiveFolder() || 0) === this.messageListEndFolder(), - isArchiveDisabled: () => UNUSED_OPTION_VALUE === FolderStore.archiveFolder(), + isArchiveDisabled: () => UNUSED_OPTION_VALUE === FolderUserStore.archiveFolder(), isArchiveVisible: () => !this.isArchiveFolder() && !this.isArchiveDisabled() && !this.isDraftFolder(), @@ -171,16 +173,16 @@ export class MessageListMailBoxUserView extends AbstractViewRight { isUnSpamVisible: () => this.isSpamFolder() && !this.isSpamDisabled() && !this.isDraftFolder() && !this.isSentFolder(), - mobileCheckedStateShow: () => ThemeStore.isMobile() ? 0 < MessageStore.messageListChecked().length : true, + mobileCheckedStateShow: () => ThemeStore.isMobile() ? 0 < MessageUserStore.messageListChecked().length : true, - mobileCheckedStateHide: () => ThemeStore.isMobile() ? !MessageStore.messageListChecked().length : true, + mobileCheckedStateHide: () => ThemeStore.isMobile() ? !MessageUserStore.messageListChecked().length : true, - messageListFocused: () => Focused.MessageList === AppStore.focusedState() + messageListFocused: () => Focused.MessageList === AppUserStore.focusedState() }); -// this.messageListChecked = MessageStore.messageListChecked; +// this.messageListChecked = MessageUserStore.messageListChecked; - this.hasCheckedOrSelectedLines = MessageStore.hasCheckedOrSelected, + this.hasCheckedOrSelectedLines = MessageUserStore.hasCheckedOrSelected, this.quotaTooltip = this.quotaTooltip.bind(this); @@ -194,7 +196,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight { '.messageListItem.focused' ); - this.selector.on('onItemSelect', message => MessageStore.selectMessage(message)); + this.selector.on('onItemSelect', message => MessageUserStore.selectMessage(message)); this.selector.on('onItemGetUid', message => (message ? message.generateUid() : '')); @@ -228,11 +230,11 @@ export class MessageListMailBoxUserView extends AbstractViewRight { rl.route.setHash(mailBox(sFolder, 1)); } - MessageStore.selectMessageByFolderAndUid(sFolder, sUid); + MessageUserStore.selectMessageByFolderAndUid(sFolder, sUid); } }); - MessageStore.messageListEndHash.subscribe((() => + MessageUserStore.messageListEndHash.subscribe((() => this.selector.scrollToFocused() ).throttle(50)); @@ -252,12 +254,12 @@ export class MessageListMailBoxUserView extends AbstractViewRight { clearCommand() { if (Settings.capa(Capa.DangerousActions)) { - showScreenPopup(FolderClearPopupView, [FolderStore.currentFolder()]); + showScreenPopup(FolderClearPopupView, [FolderUserStore.currentFolder()]); } } reloadCommand() { - if (!MessageStore.messageListCompleteLoadingThrottleForAnimation() && this.allowReload) { + if (!MessageUserStore.messageListCompleteLoadingThrottleForAnimation() && this.allowReload) { rl.app.reloadMessageList(false, true); } } @@ -265,7 +267,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight { multyForwardCommand() { showMessageComposer([ ComposeType.ForwardAsAttachment, - MessageStore.messageListCheckedOrSelected() + MessageUserStore.messageListCheckedOrSelected() ]); } @@ -273,8 +275,8 @@ export class MessageListMailBoxUserView extends AbstractViewRight { if (Settings.capa(Capa.DangerousActions)) { rl.app.deleteMessagesFromFolder( FolderType.Trash, - FolderStore.currentFolderFullNameRaw(), - MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), + FolderUserStore.currentFolderFullNameRaw(), + MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails(), false ); } @@ -283,8 +285,8 @@ export class MessageListMailBoxUserView extends AbstractViewRight { deleteCommand() { rl.app.deleteMessagesFromFolder( FolderType.Trash, - FolderStore.currentFolderFullNameRaw(), - MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), + FolderUserStore.currentFolderFullNameRaw(), + MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails(), true ); } @@ -292,8 +294,8 @@ export class MessageListMailBoxUserView extends AbstractViewRight { archiveCommand() { rl.app.deleteMessagesFromFolder( FolderType.Archive, - FolderStore.currentFolderFullNameRaw(), - MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), + FolderUserStore.currentFolderFullNameRaw(), + MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails(), true ); } @@ -301,8 +303,8 @@ export class MessageListMailBoxUserView extends AbstractViewRight { spamCommand() { rl.app.deleteMessagesFromFolder( FolderType.Spam, - FolderStore.currentFolderFullNameRaw(), - MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), + FolderUserStore.currentFolderFullNameRaw(), + MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails(), true ); } @@ -310,8 +312,8 @@ export class MessageListMailBoxUserView extends AbstractViewRight { notSpamCommand() { rl.app.deleteMessagesFromFolder( FolderType.NotSpam, - FolderStore.currentFolderFullNameRaw(), - MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), + FolderUserStore.currentFolderFullNameRaw(), + MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails(), true ); } @@ -326,7 +328,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight { } let b = moveAction(); - AppStore.focusedState(b ? Focused.MessageList : Focused.FolderList); + AppUserStore.focusedState(b ? Focused.MessageList : Focused.FolderList); moveAction(!b); } } @@ -350,7 +352,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight { } goToUpUpOrDownDown(up) { - if (MessageStore.messageListChecked().length) { + if (MessageUserStore.messageListChecked().length) { return false; } @@ -379,7 +381,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight { return false; }); - if (!SettingsStore.usePreviewPane() && !this.message()) { + if (!SettingsUserStore.usePreviewPane() && !this.message()) { this.selector.iFocusedNextHelper = up ? -1 : 1; } else { this.selector.iSelectNextHelper = up ? -1 : 1; @@ -397,7 +399,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight { useAutoSelect() { return !this.messageListDisableAutoSelect() && !/is:unseen/.test(this.mainMessageListSearch()) - && SettingsStore.usePreviewPane(); + && SettingsUserStore.usePreviewPane(); } searchEnterAction() { @@ -413,9 +415,9 @@ export class MessageListMailBoxUserView extends AbstractViewRight { cancelThreadUid() { rl.route.setHash( mailBox( - FolderStore.currentFolderFullNameHash(), - MessageStore.messageListPageBeforeThread(), - MessageStore.messageListSearch() + FolderUserStore.currentFolderFullNameHash(), + MessageUserStore.messageListPageBeforeThread(), + MessageUserStore.messageListSearch() ) ); } @@ -426,10 +428,10 @@ export class MessageListMailBoxUserView extends AbstractViewRight { * @returns {boolean} */ moveSelectedMessagesToFolder(sToFolderFullNameRaw, bCopy) { - if (MessageStore.hasCheckedOrSelected()) { + if (MessageUserStore.hasCheckedOrSelected()) { rl.app.moveMessagesToFolder( - FolderStore.currentFolderFullNameRaw(), - MessageStore.messageListCheckedOrSelectedUidsWithSubMails(), + FolderUserStore.currentFolderFullNameRaw(), + MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails(), sToFolderFullNameRaw, bCopy ); @@ -441,11 +443,11 @@ export class MessageListMailBoxUserView extends AbstractViewRight { getDragData(event) { const item = ko.dataFor(doc.elementFromPoint(event.clientX, event.clientY)); item && item.checked && item.checked(true); - const uids = MessageStore.messageListCheckedOrSelectedUidsWithSubMails(); + const uids = MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails(); item && !uids.includes(item.uid) && uids.push(item.uid); return uids.length ? { copy: event.ctrlKey, - folder: FolderStore.currentFolderFullNameRaw(), + folder: FolderUserStore.currentFolderFullNameRaw(), uids: uids } : null; } @@ -477,7 +479,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight { case MessageSetAction.SetSeen: folder = getFolderFromCacheList(sFolderFullNameRaw); if (folder) { - MessageStore.messageList.forEach(message => { + MessageUserStore.messageList.forEach(message => { if (message.isUnseen()) { ++cnt; } @@ -503,7 +505,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight { case MessageSetAction.UnsetSeen: folder = getFolderFromCacheList(sFolderFullNameRaw); if (folder) { - MessageStore.messageList.forEach(message => { + MessageUserStore.messageList.forEach(message => { if (!message.isUnseen()) { ++cnt; } @@ -536,15 +538,15 @@ export class MessageListMailBoxUserView extends AbstractViewRight { listSetSeen() { this.setAction( - FolderStore.currentFolderFullNameRaw(), + FolderUserStore.currentFolderFullNameRaw(), MessageSetAction.SetSeen, - MessageStore.messageListCheckedOrSelected() + MessageUserStore.messageListCheckedOrSelected() ); } listSetAllSeen() { this.setActionForAll( - FolderStore.currentFolderFullNameRaw(), + FolderUserStore.currentFolderFullNameRaw(), MessageSetAction.SetSeen, this.messageListEndThreadUid() ); @@ -552,25 +554,25 @@ export class MessageListMailBoxUserView extends AbstractViewRight { listUnsetSeen() { this.setAction( - FolderStore.currentFolderFullNameRaw(), + FolderUserStore.currentFolderFullNameRaw(), MessageSetAction.UnsetSeen, - MessageStore.messageListCheckedOrSelected() + MessageUserStore.messageListCheckedOrSelected() ); } listSetFlags() { this.setAction( - FolderStore.currentFolderFullNameRaw(), + FolderUserStore.currentFolderFullNameRaw(), MessageSetAction.SetFlag, - MessageStore.messageListCheckedOrSelected() + MessageUserStore.messageListCheckedOrSelected() ); } listUnsetFlags() { this.setAction( - FolderStore.currentFolderFullNameRaw(), + FolderUserStore.currentFolderFullNameRaw(), MessageSetAction.UnsetFlag, - MessageStore.messageListCheckedOrSelected() + MessageUserStore.messageListCheckedOrSelected() ); } @@ -637,20 +639,20 @@ export class MessageListMailBoxUserView extends AbstractViewRight { gotoPage(page) { page && rl.route.setHash( mailBox( - FolderStore.currentFolderFullNameHash(), + FolderUserStore.currentFolderFullNameHash(), page.value, - MessageStore.messageListSearch(), - MessageStore.messageListThreadUid() + MessageUserStore.messageListSearch(), + MessageUserStore.messageListThreadUid() ) ); } gotoThread(message) { if (message && 0 < message.threadsLen()) { - MessageStore.messageListPageBeforeThread(MessageStore.messageListPage()); + MessageUserStore.messageListPageBeforeThread(MessageUserStore.messageListPage()); rl.route.setHash( - mailBox(FolderStore.currentFolderFullNameHash(), 1, MessageStore.messageListSearch(), message.uid) + mailBox(FolderUserStore.currentFolderFullNameHash(), 1, MessageUserStore.messageListSearch(), message.uid) ); } } @@ -673,8 +675,8 @@ export class MessageListMailBoxUserView extends AbstractViewRight { dom.addEventListener('click', event => { ThemeStore.isMobile() && leftPanelDisabled(true); - if (eqs(event, '.messageList .b-message-list-wrapper') && Focused.MessageView === AppStore.focusedState()) { - AppStore.focusedState(Focused.MessageList); + if (eqs(event, '.messageList .b-message-list-wrapper') && Focused.MessageView === AppUserStore.focusedState()) { + AppUserStore.focusedState(Focused.MessageList); } let el = eqs(event, '.e-paginator .e-page'); @@ -721,12 +723,12 @@ export class MessageListMailBoxUserView extends AbstractViewRight { // delete shortcuts.add('delete', 'shift', KeyState.MessageList, () => { - MessageStore.messageListCheckedOrSelected().length && this.deleteWithoutMoveCommand(); + MessageUserStore.messageListCheckedOrSelected().length && this.deleteWithoutMoveCommand(); return false; }); // shortcuts.add('3', 'shift', KeyState.MessageList, () => { shortcuts.add('delete', '', KeyState.MessageList, () => { - MessageStore.messageListCheckedOrSelected().length && this.deleteCommand(); + MessageUserStore.messageListCheckedOrSelected().length && this.deleteCommand(); return false; }); } @@ -827,15 +829,15 @@ export class MessageListMailBoxUserView extends AbstractViewRight { // change focused state shortcuts.add('tab', 'shift', KeyState.MessageList, () => { - AppStore.focusedState(Focused.FolderList); + AppUserStore.focusedState(Focused.FolderList); return false; }); shortcuts.add('arrowleft', '', KeyState.MessageList, () => { - AppStore.focusedState(Focused.FolderList); + AppUserStore.focusedState(Focused.FolderList); return false; }); shortcuts.add('tab,arrowright', '', KeyState.MessageList, () => { - this.message() && AppStore.focusedState(Focused.MessageView); + this.message() && AppUserStore.focusedState(Focused.MessageView); return false; }); @@ -892,7 +894,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight { queueSize: 1, multipleSizeLimit: 1, hidden: { - Folder: () => FolderStore.currentFolderFullNameRaw() + Folder: () => FolderUserStore.currentFolderFullNameRaw() }, dragAndDropElement: this.dragOverArea(), dragAndDropBodyElement: this.dragOverBodyArea() @@ -907,7 +909,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight { .on('onBodyDragLeave', () => this.dragOver(false)) .on('onSelect', (sUid, oData) => { if (sUid && oData && 'message/rfc822' === oData.Type) { - MessageStore.messageListLoading(true); + MessageUserStore.messageListLoading(true); return true; } diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index 7da726596..527de3be0 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -20,18 +20,18 @@ import { doc, $htmlCL, leftPanelDisabled, keyScopeReal, moveAction, Settings } f import { inFocus } from 'Common/Utils'; import { mailToHelper, showMessageComposer } from 'Common/UtilsUser'; -import Audio from 'Common/Audio'; +import { SMAudio } from 'Common/Audio'; import { i18n } from 'Common/Translator'; import { attachmentDownload } from 'Common/Links'; import { MessageFlagsCache } from 'Common/Cache'; -import AppStore from 'Stores/User/App'; -import SettingsStore from 'Stores/User/Settings'; -import AccountStore from 'Stores/User/Account'; -import FolderStore from 'Stores/User/Folder'; -import MessageStore from 'Stores/User/Message'; +import { AppUserStore } from 'Stores/User/App'; +import { SettingsUserStore } from 'Stores/User/Settings'; +import { AccountUserStore } from 'Stores/User/Account'; +import { FolderUserStore } from 'Stores/User/Folder'; +import { MessageUserStore } from 'Stores/User/Message'; import { ThemeStore } from 'Stores/Theme'; import * as Local from 'Storage/Client'; @@ -84,22 +84,22 @@ class MessageViewMailBoxUserView extends AbstractViewRight { this.allowMessageActions = Settings.capa(Capa.MessageActions); this.allowMessageListActions = Settings.capa(Capa.MessageListActions); - this.attachmentsActions = AppStore.attachmentsActions; + this.attachmentsActions = AppUserStore.attachmentsActions; - this.message = MessageStore.message; -// this.messageListChecked = MessageStore.messageListChecked; - this.hasCheckedMessages = MessageStore.hasCheckedMessages; - this.messageListCheckedOrSelectedUidsWithSubMails = MessageStore.messageListCheckedOrSelectedUidsWithSubMails; - this.messageLoadingThrottle = MessageStore.messageLoadingThrottle; - this.messagesBodiesDom = MessageStore.messagesBodiesDom; - this.useThreads = SettingsStore.useThreads; - this.replySameFolder = SettingsStore.replySameFolder; - this.layout = SettingsStore.layout; - this.isMessageSelected = MessageStore.isMessageSelected; - this.messageActiveDom = MessageStore.messageActiveDom; - this.messageError = MessageStore.messageError; + this.message = MessageUserStore.message; +// this.messageListChecked = MessageUserStore.messageListChecked; + this.hasCheckedMessages = MessageUserStore.hasCheckedMessages; + this.messageListCheckedOrSelectedUidsWithSubMails = MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails; + this.messageLoadingThrottle = MessageUserStore.messageLoadingThrottle; + this.messagesBodiesDom = MessageUserStore.messagesBodiesDom; + this.useThreads = SettingsUserStore.useThreads; + this.replySameFolder = SettingsUserStore.replySameFolder; + this.layout = SettingsUserStore.layout; + this.isMessageSelected = MessageUserStore.isMessageSelected; + this.messageActiveDom = MessageUserStore.messageActiveDom; + this.messageError = MessageUserStore.messageError; - this.fullScreenMode = MessageStore.messageFullScreenMode; + this.fullScreenMode = MessageUserStore.messageFullScreenMode; this.messageListOfThreadsLoading = ko.observable(false).extend({ rateLimit: 1 }); this.highlightUnselectedAttachments = ko.observable(false).extend({ falseTimeout: 2000 }); @@ -191,10 +191,10 @@ class MessageViewMailBoxUserView extends AbstractViewRight { return ''; }, - messageFocused: () => Focused.MessageView === AppStore.focusedState(), + messageFocused: () => Focused.MessageView === AppUserStore.focusedState(), messageListAndMessageViewLoading: - () => MessageStore.messageListCompleteLoadingThrottle() || MessageStore.messageLoadingThrottle() + () => MessageUserStore.messageListCompleteLoadingThrottle() || MessageUserStore.messageLoadingThrottle() }); this.addSubscribables({ @@ -241,7 +241,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight { this.viewIsImportant(message.isImportant()); this.viewIsFlagged(message.isFlagged()); } else { - MessageStore.selectorMessageSelected(null); + MessageUserStore.selectorMessageSelected(null); this.viewFolder = ''; this.viewUid = ''; @@ -260,7 +260,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight { } }); - MessageStore.messageViewTrigger.subscribe(() => { + MessageUserStore.messageViewTrigger.subscribe(() => { const message = this.message(); message ? this.viewIsFlagged(message.isFlagged()) : this.viewIsFlagged(false); }); @@ -281,7 +281,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight { } closeMessageCommand() { - MessageStore.message(null); + MessageUserStore.message(null); } messageVisibilityCommand() {} @@ -292,19 +292,19 @@ class MessageViewMailBoxUserView extends AbstractViewRight { goUpCommand() { dispatchEvent(new CustomEvent('mailbox.message-list.selector.go-up', - {detail:SettingsStore.usePreviewPane() || !!this.message()} // bForceSelect + {detail:SettingsUserStore.usePreviewPane() || !!this.message()} // bForceSelect )); } goDownCommand() { dispatchEvent(new CustomEvent('mailbox.message-list.selector.go-down', - {detail:SettingsStore.usePreviewPane() || !!this.message()} // bForceSelect + {detail:SettingsUserStore.usePreviewPane() || !!this.message()} // bForceSelect )); } detectDomBackgroundColor(dom) { let color = ''; - if (dom && !SettingsStore.removeColors()) { + if (dom && !SettingsUserStore.removeColors()) { let limit = 5, aC = dom; while (!color && aC && limit--) { @@ -336,7 +336,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight { * @returns {void} */ replyOrforward(sType) { - showMessageComposer([sType, MessageStore.message()]); + showMessageComposer([sType, MessageUserStore.message()]); } checkHeaderHeight() { @@ -395,7 +395,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight { } onBuild(dom) { - this.fullScreenMode.subscribe(value => value && this.message() && AppStore.focusedState(Focused.MessageView)); + this.fullScreenMode.subscribe(value => value && this.message() && AppUserStore.focusedState(Focused.MessageView)); this.showFullInfo.subscribe(value => Local.set(ClientSideKeyName.MessageHeaderFullInfo, value ? '1' : '0')); @@ -446,16 +446,16 @@ class MessageViewMailBoxUserView extends AbstractViewRight { if (el) { event.stopPropagation(); const attachment = ko.dataFor(el); // eslint-disable-line no-invalid-this - if (attachment && Audio.supported) { + if (attachment && SMAudio.supported) { switch (true) { - case Audio.supportedMp3 && attachment.isMp3(): - Audio.playMp3(attachment.linkDownload(), attachment.fileName); + case SMAudio.supportedMp3 && attachment.isMp3(): + SMAudio.playMp3(attachment.linkDownload(), attachment.fileName); break; - case Audio.supportedOgg && attachment.isOgg(): - Audio.playOgg(attachment.linkDownload(), attachment.fileName); + case SMAudio.supportedOgg && attachment.isOgg(): + SMAudio.playOgg(attachment.linkDownload(), attachment.fileName); break; - case Audio.supportedWav && attachment.isWav(): - Audio.playWav(attachment.linkDownload(), attachment.fileName); + case SMAudio.supportedWav && attachment.isWav(): + SMAudio.playWav(attachment.linkDownload(), attachment.fileName); break; // no default } @@ -494,7 +494,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight { } }); - AppStore.focusedState.subscribe((value) => { + AppUserStore.focusedState.subscribe((value) => { if (Focused.MessageView !== value) { this.scrollMessageToTop(); this.scrollMessageToLeft(); @@ -513,17 +513,17 @@ class MessageViewMailBoxUserView extends AbstractViewRight { */ escShortcuts() { if (this.viewModelVisible && this.message()) { - const preview = SettingsStore.usePreviewPane(); + const preview = SettingsUserStore.usePreviewPane(); if (this.fullScreenMode()) { this.fullScreenMode(false); if (preview) { - AppStore.focusedState(Focused.MessageList); + AppUserStore.focusedState(Focused.MessageList); } } else if (!preview) { this.message(null); } else { - AppStore.focusedState(Focused.MessageList); + AppUserStore.focusedState(Focused.MessageList); } return false; @@ -544,7 +544,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight { // reply shortcuts.add('r,mailreply', '', [KeyState.MessageList, KeyState.MessageView], () => { - if (MessageStore.message()) { + if (MessageUserStore.message()) { this.replyCommand(); return false; } @@ -553,14 +553,14 @@ class MessageViewMailBoxUserView extends AbstractViewRight { // replaAll shortcuts.add('a', '', [KeyState.MessageList, KeyState.MessageView], () => { - if (MessageStore.message()) { + if (MessageUserStore.message()) { this.replyAllCommand(); return false; } return true; }); shortcuts.add('mailreply', 'shift', [KeyState.MessageList, KeyState.MessageView], () => { - if (MessageStore.message()) { + if (MessageUserStore.message()) { this.replyAllCommand(); return false; } @@ -569,7 +569,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight { // forward shortcuts.add('f,mailforward', '', [KeyState.MessageList, KeyState.MessageView], () => { - if (MessageStore.message()) { + if (MessageUserStore.message()) { this.forwardCommand(); return false; } @@ -579,7 +579,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight { // message information shortcuts.add('i', 'meta', [KeyState.MessageList, KeyState.MessageView], () => { - if (MessageStore.message()) { + if (MessageUserStore.message()) { this.showFullInfo(!this.showFullInfo()); } return false; @@ -587,7 +587,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight { // toggle message blockquotes shortcuts.add('b', '', [KeyState.MessageList, KeyState.MessageView], () => { - const message = MessageStore.message(); + const message = MessageUserStore.message(); if (message && message.body) { message.body.querySelectorAll('.rlBlockquoteSwitcher').forEach(node => node.click()); return false; @@ -623,18 +623,18 @@ class MessageViewMailBoxUserView extends AbstractViewRight { // change focused state shortcuts.add('arrowleft', '', KeyState.MessageView, () => { - if (!this.fullScreenMode() && this.message() && SettingsStore.usePreviewPane()) { + if (!this.fullScreenMode() && this.message() && SettingsUserStore.usePreviewPane()) { if (this.oMessageScrollerDom && 0 < this.oMessageScrollerDom.scrollLeft) { return true; } - AppStore.focusedState(Focused.MessageList); + AppUserStore.focusedState(Focused.MessageList); return false; } }); // shortcuts.add('tab', 'shift', KeyState.MessageView, (event, handler) => { shortcuts.add('tab', '', KeyState.MessageView, () => { - if (!this.fullScreenMode() && this.message() && SettingsStore.usePreviewPane()) { - AppStore.focusedState(Focused.MessageList); + if (!this.fullScreenMode() && this.message() && SettingsUserStore.usePreviewPane()) { + AppUserStore.focusedState(Focused.MessageList); } return false; }); @@ -644,42 +644,42 @@ class MessageViewMailBoxUserView extends AbstractViewRight { * @returns {boolean} */ isDraftFolder() { - return MessageStore.message() && FolderStore.draftFolder() === MessageStore.message().folder; + return MessageUserStore.message() && FolderUserStore.draftFolder() === MessageUserStore.message().folder; } /** * @returns {boolean} */ isSentFolder() { - return MessageStore.message() && FolderStore.sentFolder() === MessageStore.message().folder; + return MessageUserStore.message() && FolderUserStore.sentFolder() === MessageUserStore.message().folder; } /** * @returns {boolean} */ isSpamFolder() { - return MessageStore.message() && FolderStore.spamFolder() === MessageStore.message().folder; + return MessageUserStore.message() && FolderUserStore.spamFolder() === MessageUserStore.message().folder; } /** * @returns {boolean} */ isSpamDisabled() { - return MessageStore.message() && FolderStore.spamFolder() === UNUSED_OPTION_VALUE; + return MessageUserStore.message() && FolderUserStore.spamFolder() === UNUSED_OPTION_VALUE; } /** * @returns {boolean} */ isArchiveFolder() { - return MessageStore.message() && FolderStore.archiveFolder() === MessageStore.message().folder; + return MessageUserStore.message() && FolderUserStore.archiveFolder() === MessageUserStore.message().folder; } /** * @returns {boolean} */ isArchiveDisabled() { - return MessageStore.message() && FolderStore.archiveFolder() === UNUSED_OPTION_VALUE; + return MessageUserStore.message() && FolderUserStore.archiveFolder() === UNUSED_OPTION_VALUE; } /** @@ -694,8 +694,8 @@ class MessageViewMailBoxUserView extends AbstractViewRight { } editMessage() { - if (MessageStore.message()) { - showMessageComposer([ComposeType.Draft, MessageStore.message()]); + if (MessageUserStore.message()) { + showMessageComposer([ComposeType.Draft, MessageUserStore.message()]); } } @@ -766,7 +766,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight { oMessage.uid, oMessage.readReceipt(), i18n('READ_RECEIPT/SUBJECT', { 'SUBJECT': oMessage.subject() }), - i18n('READ_RECEIPT/BODY', { 'READ-RECEIPT': AccountStore.email() }) + i18n('READ_RECEIPT/BODY', { 'READ-RECEIPT': AccountUserStore.email() }) ); oMessage.isReadReceipt(true); diff --git a/dev/View/User/Settings/Pane.js b/dev/View/User/Settings/Pane.js index 31d5597ef..3c815b195 100644 --- a/dev/View/User/Settings/Pane.js +++ b/dev/View/User/Settings/Pane.js @@ -2,7 +2,7 @@ import { mailbox } from 'Common/Links'; import { getFolderInboxName } from 'Common/Cache'; import { leftPanelDisabled } from 'Common/Globals'; -import MessageStore from 'Stores/User/Message'; +import { MessageUserStore } from 'Stores/User/Message'; import { ThemeStore } from 'Stores/Theme'; import { AbstractViewRight } from 'Knoin/AbstractViews'; @@ -15,7 +15,7 @@ export class PaneSettingsUserView extends AbstractViewRight { } onShow() { - MessageStore.message(null); + MessageUserStore.message(null); } hideLeft(item, event) { diff --git a/snappymail/v/0.0.0/app/templates/Views/User/PopupsContacts.html b/snappymail/v/0.0.0/app/templates/Views/User/PopupsContacts.html index 4d9d8c238..a7451f68f 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/PopupsContacts.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/PopupsContacts.html @@ -33,13 +33,13 @@