Replaced tricky delegateRunOnDestroy() with koArrayWithDestroy()

koArrayWithDestroy creates ko.observableArray and calls the desired onDestroy() on entry delete.
This commit is contained in:
the-djmaze 2022-02-17 12:48:57 +01:00
parent f4bc796fb1
commit e324e2f6b6
13 changed files with 32 additions and 55 deletions

View file

@ -1,7 +1,7 @@
import 'External/User/ko';
import { isArray, arrayLength, pString, forEachObjectValue } from 'Common/Utils';
import { delegateRunOnDestroy, mailToHelper, setLayoutResizer } from 'Common/UtilsUser';
import { mailToHelper, setLayoutResizer } from 'Common/UtilsUser';
import {
Notification,
@ -333,8 +333,6 @@ class AppUser extends AbstractApp {
if (isArray(accounts)) {
// AccountUserStore.accounts.forEach(oAccount => counts[oAccount.email] = oAccount.count());
delegateRunOnDestroy(AccountUserStore.accounts());
AccountUserStore.accounts(
accounts.map(
sValue => new AccountModel(sValue/*, counts[sValue]*/)
@ -345,8 +343,6 @@ class AppUser extends AbstractApp {
}
if (isArray(oData.Result.Identities)) {
delegateRunOnDestroy(IdentityUserStore());
IdentityUserStore(
oData.Result.Identities.map(identityData => {
const identity = new IdentityModel(