mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-08 22:18:28 +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
|
|
@ -46,7 +46,7 @@ class FilterModel extends AbstractModel {
|
|||
actionType: FiltersAction.MoveTo
|
||||
});
|
||||
|
||||
this.conditions = ko.observableArray([]);
|
||||
this.conditions = ko.observableArray();
|
||||
|
||||
const fGetRealFolderName = (folderFullNameRaw) => {
|
||||
const folder = getFolderFromCacheList(folderFullNameRaw);
|
||||
|
|
@ -137,7 +137,7 @@ class FilterModel extends AbstractModel {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (this.conditions().length && this.conditions().find(cond => cond && !cond.verify())) {
|
||||
if (this.conditions.length && this.conditions.find(cond => cond && !cond.verify())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ class FilterModel extends AbstractModel {
|
|||
ID: this.id,
|
||||
Enabled: this.enabled() ? '1' : '0',
|
||||
Name: this.name(),
|
||||
Conditions: this.conditions().map(item => item.toJson()),
|
||||
Conditions: this.conditions.map(item => item.toJson()),
|
||||
ConditionsType: this.conditionsType(),
|
||||
|
||||
ActionType: this.actionType(),
|
||||
|
|
@ -259,7 +259,7 @@ class FilterModel extends AbstractModel {
|
|||
filter.actionKeep(this.actionKeep());
|
||||
filter.actionNoStop(this.actionNoStop());
|
||||
|
||||
filter.conditions(this.conditions().map(item => item.cloneSelf()));
|
||||
filter.conditions(this.conditions.map(item => item.cloneSelf()));
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class FolderModel extends AbstractModel {
|
|||
|
||||
hasSubscribedSubfolders:
|
||||
() =>
|
||||
!!folder.subFolders().find(
|
||||
!!folder.subFolders.find(
|
||||
oFolder => (oFolder.subscribed() || oFolder.hasSubscribedSubfolders()) && !oFolder.isSystemFolder()
|
||||
),
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ class FolderModel extends AbstractModel {
|
|||
return '';
|
||||
},
|
||||
|
||||
canBeDeleted: () => !folder.isSystemFolder() && !folder.subFolders().length,
|
||||
canBeDeleted: () => !folder.isSystemFolder() && !folder.subFolders.length,
|
||||
|
||||
selectableForFolderList: () => !folder.isSystemFolder() && folder.selectable,
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ class FolderModel extends AbstractModel {
|
|||
hasUnreadMessages: () => 0 < folder.messageCountUnread() && folder.printableUnreadCount(),
|
||||
|
||||
hasSubscribedUnreadMessagesSubfolders: () =>
|
||||
!!folder.subFolders().find(
|
||||
!!folder.subFolders.find(
|
||||
folder => folder.hasUnreadMessages() || folder.hasSubscribedUnreadMessagesSubfolders()
|
||||
)
|
||||
});
|
||||
|
|
|
|||
|
|
@ -72,12 +72,12 @@ class MessageModel extends AbstractModel {
|
|||
});
|
||||
|
||||
this.attachments = ko.observableArray(new AttachmentCollectionModel);
|
||||
this.attachmentsSpecData = ko.observableArray([]);
|
||||
this.threads = ko.observableArray([]);
|
||||
this.attachmentsSpecData = ko.observableArray();
|
||||
this.threads = ko.observableArray();
|
||||
|
||||
this.addComputables({
|
||||
attachmentIconClass: () => File.getCombinedIconClass(this.hasAttachments() ? this.attachmentsSpecData() : []),
|
||||
threadsLen: () => this.threads().length,
|
||||
threadsLen: () => this.threads.length,
|
||||
isImportant: () => MessagePriority.High === this.priority(),
|
||||
});
|
||||
}
|
||||
|
|
@ -502,7 +502,7 @@ class MessageModel extends AbstractModel {
|
|||
el.src = attachment.linkPreview();
|
||||
}
|
||||
} else if (data.xSrcLocation) {
|
||||
const attachment = this.attachments().find(item => data.xSrcLocation === item.contentLocation)
|
||||
const attachment = this.attachments.find(item => data.xSrcLocation === item.contentLocation)
|
||||
|| findAttachmentByCid(data.xSrcLocation);
|
||||
if (attachment && attachment.download) {
|
||||
el.loading = 'lazy';
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ class SieveScriptModel extends AbstractModel
|
|||
hasChanges: false
|
||||
});
|
||||
|
||||
this.filters = ko.observableArray([]);
|
||||
this.filters = ko.observableArray();
|
||||
// this.saving = ko.observable(false).extend({ throttle: 200 });
|
||||
|
||||
this.addSubscribables({
|
||||
|
|
@ -296,7 +296,7 @@ class SieveScriptModel extends AbstractModel
|
|||
|
||||
verify() {
|
||||
this.nameError(!this.name().trim());
|
||||
this.bodyError(this.allowFilters() ? !this.filters().length : !this.body().trim());
|
||||
this.bodyError(this.allowFilters() ? !this.filters.length : !this.body().trim());
|
||||
return !this.nameError() && !this.bodyError();
|
||||
}
|
||||
|
||||
|
|
@ -305,7 +305,7 @@ class SieveScriptModel extends AbstractModel
|
|||
name: this.name(),
|
||||
active: this.active() ? '1' : '0',
|
||||
body: this.body(),
|
||||
filters: this.filters().map(item => item.toJson())
|
||||
filters: this.filters.map(item => item.toJson())
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue