some ko.computed() to addComputables()/addComputablesTo()

This commit is contained in:
djmaze 2021-09-03 16:37:20 +02:00
parent 099560ca6a
commit 023c8f603b
9 changed files with 110 additions and 107 deletions

View file

@ -1,7 +1,7 @@
import ko from 'ko';
import { i18n } from 'Common/Translator';
import { isArray, arrayLength, pString } from 'Common/Utils';
import { isArray, arrayLength, pString, addComputablesTo } from 'Common/Utils';
import { createElement } from 'Common/Globals';
import { AccountUserStore } from 'Stores/User/Account';
@ -141,8 +141,10 @@ export const PgpUserStore = new class {
this.openpgpkeys = ko.observableArray();
this.openpgpKeyring = null;
this.openpgpkeysPublic = ko.computed(() => this.openpgpkeys.filter(item => item && !item.isPrivate));
this.openpgpkeysPrivate = ko.computed(() => this.openpgpkeys.filter(item => item && item.isPrivate));
addComputablesTo(this, {
openpgpkeysPublic: () => this.openpgpkeys.filter(item => item && !item.isPrivate),
openpgpkeysPrivate: () => this.openpgpkeys.filter(item => item && item.isPrivate)
});
}
/**