mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
Replaced tricky delegateRunOnDestroy() with koArrayWithDestroy()
koArrayWithDestroy creates ko.observableArray and calls the desired onDestroy() on entry delete.
This commit is contained in:
parent
f4bc796fb1
commit
e324e2f6b6
13 changed files with 32 additions and 55 deletions
|
|
@ -13,8 +13,9 @@ import {
|
|||
} from 'Common/EnumsUser';
|
||||
|
||||
import { inFocus, pInt, isArray, arrayLength, forEachObjectEntry } from 'Common/Utils';
|
||||
import { delegateRunOnDestroy, initFullscreen } from 'Common/UtilsUser';
|
||||
import { initFullscreen } from 'Common/UtilsUser';
|
||||
import { encodeHtml, HtmlEditor, htmlToPlain } from 'Common/Html';
|
||||
import { koArrayWithDestroy } from 'External/ko';
|
||||
|
||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
import { serverRequest } from 'Common/Links';
|
||||
|
|
@ -237,7 +238,7 @@ class ComposePopupView extends AbstractViewPopup {
|
|||
this.bcc.focused = ko.observable(false);
|
||||
this.bcc.focused.subscribe(value => value && (this.sLastFocusedField = 'bcc'));
|
||||
|
||||
this.attachments = ko.observableArray();
|
||||
this.attachments = koArrayWithDestroy();
|
||||
|
||||
this.dragAndDropOver = ko.observable(false).extend({ debounce: 1 });
|
||||
this.dragAndDropVisible = ko.observable(false).extend({ debounce: 1 });
|
||||
|
|
@ -1380,7 +1381,6 @@ class ComposePopupView extends AbstractViewPopup {
|
|||
const attachment = this.getAttachmentById(id);
|
||||
if (attachment) {
|
||||
this.attachments.remove(attachment);
|
||||
delegateRunOnDestroy(attachment);
|
||||
oJua && oJua.cancel(id);
|
||||
}
|
||||
};
|
||||
|
|
@ -1535,7 +1535,6 @@ class ComposePopupView extends AbstractViewPopup {
|
|||
this.pgpSign(false);
|
||||
this.pgpEncrypt(false);
|
||||
|
||||
delegateRunOnDestroy(this.attachments());
|
||||
this.attachments([]);
|
||||
|
||||
this.dragAndDropOver(false);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import ko from 'ko';
|
||||
import { koArrayWithDestroy } from 'External/ko';
|
||||
|
||||
import {
|
||||
SaveSettingsStep,
|
||||
|
|
@ -8,7 +8,7 @@ import {
|
|||
import { ComposeType } from 'Common/EnumsUser';
|
||||
|
||||
import { arrayLength, pInt } from 'Common/Utils';
|
||||
import { download, delegateRunOnDestroy, computedPaginatorHelper, showMessageComposer } from 'Common/UtilsUser';
|
||||
import { download, computedPaginatorHelper, showMessageComposer } from 'Common/UtilsUser';
|
||||
|
||||
import { Selector } from 'Common/Selector';
|
||||
import { serverRequestRaw, serverRequest } from 'Common/Links';
|
||||
|
|
@ -66,7 +66,7 @@ class ContactsPopupView extends AbstractViewPopup {
|
|||
|
||||
this.contacts = ContactUserStore;
|
||||
|
||||
this.viewProperties = ko.observableArray();
|
||||
this.viewProperties = koArrayWithDestroy();
|
||||
|
||||
this.useCheckboxesInList = SettingsUserStore.useCheckboxesInList;
|
||||
|
||||
|
|
@ -346,10 +346,7 @@ class ContactsPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
setTimeout(() => {
|
||||
contacts.forEach(contact => {
|
||||
ContactUserStore.remove(contact);
|
||||
delegateRunOnDestroy(contact);
|
||||
});
|
||||
contacts.forEach(contact => ContactUserStore.remove(contact));
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
|
@ -373,7 +370,6 @@ class ContactsPopupView extends AbstractViewPopup {
|
|||
|
||||
removeProperty(oProp) {
|
||||
this.viewProperties.remove(oProp);
|
||||
delegateRunOnDestroy(oProp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -397,7 +393,6 @@ class ContactsPopupView extends AbstractViewPopup {
|
|||
|
||||
this.viewID(id);
|
||||
|
||||
// delegateRunOnDestroy(this.viewProperties());
|
||||
// this.viewProperties([]);
|
||||
this.viewProperties(contact.properties);
|
||||
|
||||
|
|
@ -436,7 +431,6 @@ class ContactsPopupView extends AbstractViewPopup {
|
|||
|
||||
this.contactsCount(count);
|
||||
|
||||
delegateRunOnDestroy(ContactUserStore());
|
||||
ContactUserStore(list);
|
||||
|
||||
ContactUserStore.loading(false);
|
||||
|
|
@ -516,7 +510,6 @@ class ContactsPopupView extends AbstractViewPopup {
|
|||
this.search('');
|
||||
this.contactsCount(0);
|
||||
|
||||
delegateRunOnDestroy(ContactUserStore());
|
||||
ContactUserStore([]);
|
||||
|
||||
this.sLastComposeFocusedField = '';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import ko from 'ko';
|
|||
|
||||
import { getNotification, i18nToNodes } from 'Common/Translator';
|
||||
import { addObservablesTo } from 'External/ko';
|
||||
import { delegateRunOnDestroy } from 'Common/UtilsUser';
|
||||
|
||||
import Remote from 'Remote/User/Fetch';
|
||||
import { FilterModel } from 'Model/Filter';
|
||||
|
|
@ -78,7 +77,6 @@ class SieveScriptPopupView extends AbstractViewPopup {
|
|||
|
||||
deleteFilter(filter) {
|
||||
this.script().filters.remove(filter);
|
||||
delegateRunOnDestroy(filter);
|
||||
}
|
||||
|
||||
addFilter() {
|
||||
|
|
@ -103,7 +101,6 @@ class SieveScriptPopupView extends AbstractViewPopup {
|
|||
filters = script.filters(),
|
||||
index = filters.indexOf(filter);
|
||||
if (-1 < index) {
|
||||
delegateRunOnDestroy(filters[index]);
|
||||
filters[index] = clonedFilter;
|
||||
script.filters(filters);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue