mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-27 19:19:21 +03:00
Cleanup calls to Knockout observableArray
Improved Knockout observableArray
This commit is contained in:
parent
fa5476e486
commit
b6f0b634fb
47 changed files with 251 additions and 276 deletions
|
|
@ -67,7 +67,7 @@ class GeneralAdminSettings {
|
|||
: '';
|
||||
|
||||
this.themesOptions = ko.computed(() =>
|
||||
this.themes().map(theme => ({ optValue: theme, optText: convertThemeName(theme) }))
|
||||
this.themes.map(theme => ({ optValue: theme, optText: convertThemeName(theme) }))
|
||||
);
|
||||
|
||||
this.languageFullName = ko.computed(() => convertLangName(this.language()));
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ class PackagesAdminSettings {
|
|||
this.packagesMainUpdatable = PackageStore.packagesMainUpdatable;
|
||||
|
||||
this.packagesCurrent = ko.computed(() =>
|
||||
this.packages().filter(item => item && item.installed && !item.compare)
|
||||
this.packages.filter(item => item && item.installed && !item.compare)
|
||||
);
|
||||
this.packagesAvailableForUpdate = ko.computed(() =>
|
||||
this.packages().filter(item => item && item.installed && !!item.compare)
|
||||
this.packages.filter(item => item && item.installed && !!item.compare)
|
||||
);
|
||||
this.packagesAvailableForInstallation = ko.computed(() =>
|
||||
this.packages().filter(item => item && !item.installed)
|
||||
this.packages.filter(item => item && !item.installed)
|
||||
);
|
||||
|
||||
this.visibility = ko.computed(() => (PackageStore.packages.loading() ? 'visible' : 'hidden'));
|
||||
|
|
@ -47,7 +47,7 @@ class PackagesAdminSettings {
|
|||
}
|
||||
}
|
||||
|
||||
this.packages().forEach(item => {
|
||||
this.packages.forEach(item => {
|
||||
if (item && packageToRequest && item.loading && item.loading() && packageToRequest.file === item.file) {
|
||||
packageToRequest.loading(false);
|
||||
item.loading(false);
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class FiltersUserSettings {
|
|||
Remote.filtersScriptActivate(
|
||||
(result, data) => {
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
this.scripts().forEach(script => script.active(script.name() === name));
|
||||
this.scripts.forEach(script => script.active(script.name() === name));
|
||||
} else {
|
||||
this.setError((data && data.ErrorCode)
|
||||
? (data.ErrorMessageAdditional || getNotification(data.ErrorCode))
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class OpenPgpUserSettings {
|
|||
this.openPgpKeyForDeletion(null);
|
||||
|
||||
if (openPgpKeyToRemove && PgpStore.openpgpKeyring) {
|
||||
const findedItem = PgpStore.openpgpkeys().find(key => openPgpKeyToRemove === key);
|
||||
const findedItem = PgpStore.openpgpkeys.find(key => openPgpKeyToRemove === key);
|
||||
if (findedItem) {
|
||||
PgpStore.openpgpkeys.remove(findedItem);
|
||||
delegateRunOnDestroy(findedItem);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class ThemesUserSettings {
|
|||
constructor() {
|
||||
this.theme = ThemeStore.theme;
|
||||
this.themes = ThemeStore.themes;
|
||||
this.themesObjects = ko.observableArray([]);
|
||||
this.themesObjects = ko.observableArray();
|
||||
|
||||
this.background = {};
|
||||
this.background.name = ThemeStore.themeBackgroundName;
|
||||
|
|
@ -27,7 +27,7 @@ class ThemesUserSettings {
|
|||
this.themeTrigger = ko.observable(SaveSettingsStep.Idle).extend({ throttle: 100 });
|
||||
|
||||
this.theme.subscribe((value) => {
|
||||
this.themesObjects().forEach(theme => {
|
||||
this.themesObjects.forEach(theme => {
|
||||
theme.selected(value === theme.name);
|
||||
});
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ class ThemesUserSettings {
|
|||
const currentTheme = this.theme();
|
||||
|
||||
this.themesObjects(
|
||||
this.themes().map(theme => ({
|
||||
this.themes.map(theme => ({
|
||||
name: theme,
|
||||
nameDisplay: convertThemeName(theme),
|
||||
selected: ko.observable(theme === currentTheme),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue