From 671062af31f3f52d36c3bc5d2ba955af63be7b8d Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Mon, 25 Apr 2022 09:40:38 +0200 Subject: [PATCH] Resolve #348 --- dev/Model/Attachment.js | 2 +- dev/View/User/MailBox/MessageView.js | 23 +++++++------------ .../templates/Views/User/MailMessageView.html | 5 ++-- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/dev/Model/Attachment.js b/dev/Model/Attachment.js index c5522a1dc..16271e4a9 100644 --- a/dev/Model/Attachment.js +++ b/dev/Model/Attachment.js @@ -14,7 +14,7 @@ export class AttachmentModel extends AbstractModel { constructor() { super(); - this.checked = ko.observable(false); + this.checked = ko.observable(true); this.mimeType = ''; this.fileName = ''; diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index a3dcf3d32..70755189f 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -93,7 +93,7 @@ export class MailMessageView extends AbstractViewRight { }, this.messageVisibility); this.addObservables({ - showAttachmentControls: false, + showAttachmentControls: !!Local.get(ClientSideKeyNameMessageAttachmentControls), downloadAsZipLoading: false, lastReplyAction_: '', showFullInfo: '1' === Local.get(ClientSideKeyNameMessageHeaderFullInfo), @@ -124,8 +124,6 @@ export class MailMessageView extends AbstractViewRight { this.messageListOfThreadsLoading = ko.observable(false).extend({ rateLimit: 1 }); this.highlightUnselectedAttachments = ko.observable(false).extend({ falseTimeout: 2000 }); - this.showAttachmentControlsState = v => Local.set(ClientSideKeyNameMessageAttachmentControls, !!v); - this.downloadAsZipError = ko.observable(false).extend({ falseTimeout: 7000 }); this.messageDomFocused = ko.observable(false).extend({ rateLimit: 0 }); @@ -134,7 +132,7 @@ export class MailMessageView extends AbstractViewRight { this.viewHash = ''; this.addComputables({ - allowAttachmentControls: () => this.attachmentsActions.length && SettingsCapa('AttachmentsActions'), + allowAttachmentControls: () => arrayLength(attachmentsActions) && SettingsCapa('AttachmentsActions'), downloadAsZipAllowed: () => this.attachmentsActions.includes('zip') && this.allowAttachmentControls(), @@ -180,26 +178,15 @@ export class MailMessageView extends AbstractViewRight { }); this.addSubscribables({ - showAttachmentControls: v => currentMessage() - && currentMessage().attachments.forEach(item => item && item.checked(!!v)), - lastReplyAction_: value => Local.set(ClientSideKeyNameLastReplyAction, value), message: message => { MessageUserStore.activeDom(null); if (message) { - this.showAttachmentControls(false); - if (Local.get(ClientSideKeyNameMessageAttachmentControls)) { - setTimeout(() => { - this.showAttachmentControls(true); - }, 50); - } - if (this.viewHash !== message.hash) { this.scrollMessageToTop(); } - this.viewHash = message.hash; this.viewFromShort(message.fromToLine(true, true)); this.viewFromDkimData(message.fromDkimData()); @@ -509,6 +496,12 @@ export class MailMessageView extends AbstractViewRight { oMessageScrollerDom().scrollLeft = 0; } + toggleAttachmentControls() { + const b = !this.showAttachmentControls(); + this.showAttachmentControls(b); + Local.set(ClientSideKeyNameMessageAttachmentControls, b); + } + downloadAsZip() { const hashes = (currentMessage() ? currentMessage().attachments : []) .map(item => (item && !item.isLinked() && item.checked() ? item.download : '')) diff --git a/snappymail/v/0.0.0/app/templates/Views/User/MailMessageView.html b/snappymail/v/0.0.0/app/templates/Views/User/MailMessageView.html index fb751826a..2ec62a62c 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/MailMessageView.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/MailMessageView.html @@ -245,7 +245,7 @@ click: function () { checked(!checked()); return false }"> - ⚙ + ⚙