mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 22:17:03 +03:00
Cleanup knockout subscribables
This commit is contained in:
parent
5748dea4bc
commit
b2a492bdab
27 changed files with 73 additions and 75 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import ko from 'ko';
|
||||
import { addObservablesTo } from 'Common/Utils';
|
||||
import { addObservablesTo } from 'External/ko';
|
||||
|
||||
export const AccountUserStore = {
|
||||
accounts: ko.observableArray(),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Scope } from 'Common/Enums';
|
||||
import { keyScope, leftPanelDisabled, SettingsGet, elementById } from 'Common/Globals';
|
||||
import { addObservablesTo } from 'Common/Utils';
|
||||
import { addObservablesTo } from 'External/ko';
|
||||
import { ThemeStore } from 'Stores/Theme';
|
||||
|
||||
export const AppUserStore = {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import ko from 'ko';
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
import { pInt, addObservablesTo } from 'Common/Utils';
|
||||
import { pInt } from 'Common/Utils';
|
||||
import { addObservablesTo } from 'External/ko';
|
||||
import Remote from 'Remote/User/Fetch';
|
||||
|
||||
export const ContactUserStore = ko.observableArray();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ import { koComputable } from 'External/ko';
|
|||
|
||||
import { FolderType, FolderSortMode } from 'Common/EnumsUser';
|
||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
import { addObservablesTo, addSubscribablesTo, addComputablesTo, forEachObjectEntry } from 'Common/Utils';
|
||||
import { forEachObjectEntry } from 'Common/Utils';
|
||||
import { addObservablesTo, addSubscribablesTo, addComputablesTo } from 'External/ko';
|
||||
import { getFolderInboxName, getFolderFromCacheList } from 'Common/Cache';
|
||||
import { Settings } from 'Common/Globals';
|
||||
//import Remote from 'Remote/User/Fetch'; Circular dependency
|
||||
|
|
@ -78,20 +79,22 @@ export const FolderUserStore = new class {
|
|||
});
|
||||
|
||||
const
|
||||
fRemoveSystemFolderType = (observable) => () => {
|
||||
const folder = getFolderFromCacheList(observable());
|
||||
folder && folder.type(FolderType.User);
|
||||
subscribeRemoveSystemFolder = observable => {
|
||||
observable.subscribe(() => {
|
||||
const folder = getFolderFromCacheList(observable());
|
||||
folder && folder.type(FolderType.User);
|
||||
}, self, 'beforeChange');
|
||||
},
|
||||
fSetSystemFolderType = type => value => {
|
||||
const folder = getFolderFromCacheList(value);
|
||||
folder && folder.type(type);
|
||||
};
|
||||
|
||||
self.sentFolder.subscribe(fRemoveSystemFolderType(self.sentFolder), self, 'beforeChange');
|
||||
self.draftsFolder.subscribe(fRemoveSystemFolderType(self.draftsFolder), self, 'beforeChange');
|
||||
self.spamFolder.subscribe(fRemoveSystemFolderType(self.spamFolder), self, 'beforeChange');
|
||||
self.trashFolder.subscribe(fRemoveSystemFolderType(self.trashFolder), self, 'beforeChange');
|
||||
self.archiveFolder.subscribe(fRemoveSystemFolderType(self.archiveFolder), self, 'beforeChange');
|
||||
subscribeRemoveSystemFolder(self.sentFolder);
|
||||
subscribeRemoveSystemFolder(self.draftsFolder);
|
||||
subscribeRemoveSystemFolder(self.spamFolder);
|
||||
subscribeRemoveSystemFolder(self.trashFolder);
|
||||
subscribeRemoveSystemFolder(self.archiveFolder);
|
||||
|
||||
addSubscribablesTo(self, {
|
||||
sentFolder: fSetSystemFolderType(FolderType.Sent),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import ko from 'ko';
|
|||
|
||||
import { Capa } from 'Common/Enums';
|
||||
import { SettingsCapa } from 'Common/Globals';
|
||||
import { delegateRunOnDestroy } from 'Common/UtilsUser';
|
||||
|
||||
//import { EmailModel } from 'Model/Email';
|
||||
//import { OpenPgpKeyModel } from 'Model/OpenPgpKey';
|
||||
|
|
@ -60,7 +59,6 @@ export const GnuPGUserStore = new class {
|
|||
} else {
|
||||
this.publicKeys.remove(key);
|
||||
}
|
||||
delegateRunOnDestroy(key);
|
||||
}
|
||||
}, {
|
||||
KeyId: key.id,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ import { koComputable } from 'External/ko';
|
|||
import { Scope, Notification } from 'Common/Enums';
|
||||
import { MessageSetAction } from 'Common/EnumsUser';
|
||||
import { $htmlCL, elementById } from 'Common/Globals';
|
||||
import { arrayLength, pInt, pString, addObservablesTo, addComputablesTo, addSubscribablesTo } from 'Common/Utils';
|
||||
import { arrayLength, pInt, pString } from 'Common/Utils';
|
||||
import { addObservablesTo, addComputablesTo, addSubscribablesTo } from 'External/ko';
|
||||
|
||||
import {
|
||||
getFolderInboxName,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { SMAudio } from 'Common/Audio';
|
||||
import * as Links from 'Common/Links';
|
||||
import { addObservablesTo } from 'Common/Utils';
|
||||
import { addObservablesTo } from 'External/ko';
|
||||
import { fireEvent } from 'Common/Globals';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { arrayLength } from 'Common/Utils';
|
||||
import { delegateRunOnDestroy } from 'Common/UtilsUser';
|
||||
|
||||
import Remote from 'Remote/User/Fetch';
|
||||
|
||||
|
|
@ -82,7 +81,6 @@ class OpenPgpKeyModel {
|
|||
OpenPGPUserStore.publicKeys.remove(this);
|
||||
storeOpenPgpKeys(OpenPGPUserStore.publicKeys, publicKeysItem);
|
||||
}
|
||||
delegateRunOnDestroy(this);
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ import ko from 'ko';
|
|||
import { koComputable } from 'External/ko';
|
||||
|
||||
import { Layout, EditorDefaultType } from 'Common/EnumsUser';
|
||||
import { pInt, addObservablesTo } from 'Common/Utils';
|
||||
import { pInt } from 'Common/Utils';
|
||||
import { addObservablesTo } from 'External/ko';
|
||||
import { $htmlCL, SettingsGet, fireEvent } from 'Common/Globals';
|
||||
import { ThemeStore } from 'Stores/Theme';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue