Prevent memory leaks in *Model

This commit is contained in:
djmaze 2020-10-25 11:46:58 +01:00
parent 48a9a03762
commit d7a4639d6b
22 changed files with 221 additions and 225 deletions

View file

@ -24,16 +24,18 @@ class ComposeAttachmentModel extends AbstractModel {
this.contentLocation = contentLocation;
this.fromMessage = false;
this.fileName = ko.observable(fileName);
this.size = ko.observable(size);
this.tempName = ko.observable('');
this.addObservables({
fileName: fileName,
size: size,
tempName: '',
this.progress = ko.observable(0);
this.error = ko.observable('');
this.waiting = ko.observable(true);
this.uploading = ko.observable(false);
this.enabled = ko.observable(true);
this.complete = ko.observable(false);
progress: 0,
error: '',
waiting: true,
uploading: false,
enabled: true,
complete: false
});
this.progressText = ko.computed(() => {
const p = this.progress();
@ -56,15 +58,6 @@ class ComposeAttachmentModel extends AbstractModel {
this.mimeType = ko.computed(() => File.getContentType(this.fileName()));
this.fileExt = ko.computed(() => File.getExtension(this.fileName()));
this.regDisposables([
this.progressText,
this.progressStyle,
this.title,
this.friendlySize,
this.mimeType,
this.fileExt
]);
}
static fromAttachment(item)