Switch from ko.computed to ko.pureComputed

This should provide performance and memory benefits over regular computed observables
This commit is contained in:
djmaze 2021-12-31 13:30:05 +01:00
parent ac2238a23f
commit 954de06f86
18 changed files with 55 additions and 37 deletions

View file

@ -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') },

View file

@ -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'],
[['', '']],

View file

@ -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(
[],
[['', '']],

View file

@ -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(),
[

View file

@ -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,