From 39f39db44701ab17e5d9e067e91c94b2e9ba52ec Mon Sep 17 00:00:00 2001 From: djmaze Date: Wed, 23 Sep 2020 12:18:36 +0200 Subject: [PATCH] Resolve https://github.com/the-djmaze/rainloop-webmail/issues/7 --- dev/View/Popup/Compose.js | 56 +++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 492f71b23..f3572a5ab 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -1048,7 +1048,30 @@ class ComposePopupView extends AbstractViewNext { const downloads = this.getAttachmentsDownloadsForUpload(); if (Array.isNotEmpty(downloads)) { - Remote.messageUploadAttachments(()=>this.onMessageUploadAttachments(), downloads); + Remote.messageUploadAttachments((sResult, oData) => { + if (StorageResultType.Success === sResult && oData && oData.Result) { + Object.entries(oData.Result).forEach(([tempName, id]) => { + const attachment = this.getAttachmentById(id); + if (attachment) { + attachment.tempName(tempName); + attachment + .waiting(false) + .uploading(false) + .complete(true); + } + }); + } else { + this.attachments().forEach(attachment => { + if (attachment && attachment.fromMessage) { + attachment + .waiting(false) + .uploading(false) + .complete(true) + .error(getUploadErrorDescByCode(UploadErrorCode.FileNoUploaded)); + } + }); + } + }, downloads); } if (identity) { @@ -1056,25 +1079,6 @@ class ComposePopupView extends AbstractViewNext { } } - onMessageUploadAttachments(sResult, oData) { - if (StorageResultType.Success === sResult && oData && oData.Result) { - if (!this.viewModelVisibility()) { - oData.Result.forEach((id, tempName) => { - const attachment = this.getAttachmentById(id); - if (attachment) { - attachment.tempName(tempName); - attachment - .waiting(false) - .uploading(false) - .complete(true); - } - }); - } - } else { - this.setMessageAttachmentFailedDownloadText(); - } - } - setFocusInPopup() { if (!bMobileDevice) { setTimeout(() => { @@ -1404,18 +1408,6 @@ class ComposePopupView extends AbstractViewNext { } } - setMessageAttachmentFailedDownloadText() { - this.attachments().forEach(attachment => { - if (attachment && attachment.fromMessage) { - attachment - .waiting(false) - .uploading(false) - .complete(true) - .error(getUploadErrorDescByCode(UploadErrorCode.FileNoUploaded)); - } - }); - } - /** * @param {boolean=} includeAttachmentInProgress = true * @returns {boolean}