mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 05:59:21 +03:00
Prevent memory leaks in *Model
This commit is contained in:
parent
48a9a03762
commit
d7a4639d6b
22 changed files with 221 additions and 225 deletions
|
|
@ -8,13 +8,15 @@ class FilterConditionModel extends AbstractModel {
|
|||
constructor() {
|
||||
super();
|
||||
|
||||
this.field = ko.observable(FilterConditionField.From);
|
||||
this.type = ko.observable(FilterConditionType.Contains);
|
||||
this.value = ko.observable('');
|
||||
this.value.error = ko.observable(false);
|
||||
this.addObservables({
|
||||
field: FilterConditionField.From,
|
||||
type: FilterConditionType.Contains,
|
||||
value: '',
|
||||
valueError: false,
|
||||
|
||||
this.valueSecond = ko.observable('');
|
||||
this.valueSecond.error = ko.observable(false);
|
||||
valueSecond: '',
|
||||
valueSecondError: false
|
||||
});
|
||||
|
||||
this.template = ko.computed(() => {
|
||||
let template = '';
|
||||
|
|
@ -33,22 +35,22 @@ class FilterConditionModel extends AbstractModel {
|
|||
return template;
|
||||
}, this);
|
||||
|
||||
this.field.subscribe(() => {
|
||||
this.value('');
|
||||
this.valueSecond('');
|
||||
this.addSubscribables({
|
||||
field: () => {
|
||||
this.value('');
|
||||
this.valueSecond('');
|
||||
}
|
||||
});
|
||||
|
||||
this.regDisposables([this.template]);
|
||||
}
|
||||
|
||||
verify() {
|
||||
if (!this.value()) {
|
||||
this.value.error(true);
|
||||
this.valueError(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FilterConditionField.Header === this.field() && !this.valueSecond()) {
|
||||
this.valueSecond.error(true);
|
||||
this.valueSecondError(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue