mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
Switch from ko.computed to ko.pureComputed
This should provide performance and memory benefits over regular computed observables
This commit is contained in:
parent
ac2238a23f
commit
954de06f86
18 changed files with 55 additions and 37 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import ko from 'ko';
|
||||
import { koComputable } from 'External/ko';
|
||||
|
||||
import { i18n, trigger as translatorTrigger } from 'Common/Translator';
|
||||
|
||||
|
|
@ -25,10 +25,10 @@ class AdvancedSearchPopupView extends AbstractViewPopup {
|
|||
unseen: false
|
||||
});
|
||||
|
||||
this.showMultisearch = ko.computed(() => FolderUserStore.hasCapability('MULTISEARCH'));
|
||||
this.showMultisearch = koComputable(() => FolderUserStore.hasCapability('MULTISEARCH'));
|
||||
|
||||
let prefix = 'SEARCH/LABEL_ADV_DATE_';
|
||||
this.selectedDates = ko.computed(() => {
|
||||
this.selectedDates = koComputable(() => {
|
||||
translatorTrigger();
|
||||
return [
|
||||
{ id: -1, name: i18n(prefix + 'ALL') },
|
||||
|
|
@ -42,7 +42,7 @@ class AdvancedSearchPopupView extends AbstractViewPopup {
|
|||
});
|
||||
|
||||
prefix = 'SEARCH/LABEL_ADV_SUBFOLDERS_';
|
||||
this.selectedTree = ko.computed(() => {
|
||||
this.selectedTree = koComputable(() => {
|
||||
translatorTrigger();
|
||||
return [
|
||||
{ id: '', name: i18n(prefix + 'NONE') },
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import ko from 'ko';
|
||||
import { koComputable } from 'External/ko';
|
||||
|
||||
import { FilterAction } from 'Model/Filter';
|
||||
import { FilterConditionField, FilterConditionType } from 'Model/FilterCondition';
|
||||
|
|
@ -27,7 +28,7 @@ class FilterPopupView extends AbstractViewPopup {
|
|||
this.fTrueCallback = null;
|
||||
|
||||
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
|
||||
this.folderSelectList = ko.computed(() =>
|
||||
this.folderSelectList = koComputable(() =>
|
||||
folderListOptionsBuilder(
|
||||
[SettingsGet('SieveAllowFileintoInbox') ? '' : 'INBOX'],
|
||||
[['', '']],
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import ko from 'ko';
|
||||
import { koComputable } from 'External/ko';
|
||||
|
||||
import { Notification } from 'Common/Enums';
|
||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
|
|
@ -26,7 +26,7 @@ class FolderCreatePopupView extends AbstractViewPopup {
|
|||
selectedParentValue: UNUSED_OPTION_VALUE
|
||||
});
|
||||
|
||||
this.parentFolderSelectList = ko.computed(() =>
|
||||
this.parentFolderSelectList = koComputable(() =>
|
||||
folderListOptionsBuilder(
|
||||
[],
|
||||
[['', '']],
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import ko from 'ko';
|
||||
import { koComputable } from 'External/ko';
|
||||
|
||||
import { SetSystemFoldersNotification } from 'Common/EnumsUser';
|
||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
|
|
@ -24,7 +25,7 @@ class FolderSystemPopupView extends AbstractViewPopup {
|
|||
|
||||
this.notification = ko.observable('');
|
||||
|
||||
this.folderSelectList = ko.computed(() =>
|
||||
this.folderSelectList = koComputable(() =>
|
||||
folderListOptionsBuilder(
|
||||
FolderUserStore.folderListSystemNames(),
|
||||
[
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import ko from 'ko';
|
||||
import { koComputable } from 'External/ko';
|
||||
|
||||
import { convertLangName } from 'Common/Translator';
|
||||
|
||||
|
|
@ -13,7 +14,7 @@ class LanguagesPopupView extends AbstractViewPopup {
|
|||
|
||||
this.langs = ko.observableArray();
|
||||
|
||||
this.languages = ko.computed(() => {
|
||||
this.languages = koComputable(() => {
|
||||
const userLanguage = this.userLanguage();
|
||||
return this.langs.map(language => ({
|
||||
key: language,
|
||||
|
|
|
|||
|
|
@ -64,10 +64,6 @@ export class MailMessageList extends AbstractViewRight {
|
|||
|
||||
this.messageList = MessageUserStore.list;
|
||||
|
||||
this.sortSupported = ko.computed(() =>
|
||||
FolderUserStore.hasCapability('SORT') | FolderUserStore.hasCapability('ESORT')
|
||||
);
|
||||
|
||||
this.composeInEdit = AppUserStore.composeInEdit;
|
||||
|
||||
this.isMobile = ThemeStore.isMobile;
|
||||
|
|
@ -107,6 +103,9 @@ export class MailMessageList extends AbstractViewRight {
|
|||
|
||||
this.addComputables({
|
||||
|
||||
sortSupported: () =>
|
||||
FolderUserStore.hasCapability('SORT') | FolderUserStore.hasCapability('ESORT'),
|
||||
|
||||
folderMenuForMove: () =>
|
||||
folderListOptionsBuilder(
|
||||
[FolderUserStore.currentFolderFullName()],
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import { ThemeStore } from 'Stores/Theme';
|
|||
import Remote from 'Remote/User/Fetch';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
//import { clearCache } from 'Common/Cache';
|
||||
//import { koComputable } from 'External/ko';
|
||||
|
||||
export class SystemDropDownUserView extends AbstractViewRight {
|
||||
constructor() {
|
||||
|
|
@ -32,8 +33,8 @@ export class SystemDropDownUserView extends AbstractViewRight {
|
|||
this.accounts = AccountUserStore.accounts;
|
||||
this.accountsLoading = AccountUserStore.loading;
|
||||
/*
|
||||
this.accountsUnreadCount = : ko.computed(() => 0);
|
||||
this.accountsUnreadCount = : ko.computed(() => AccountUserStore.accounts().reduce((result, item) => result + item.count(), 0));
|
||||
this.accountsUnreadCount = : koComputable(() => 0);
|
||||
this.accountsUnreadCount = : koComputable(() => AccountUserStore.accounts().reduce((result, item) => result + item.count(), 0));
|
||||
*/
|
||||
|
||||
this.addObservables({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue