This commit is contained in:
the-djmaze 2022-11-17 21:04:04 +01:00
parent 7e1b85d023
commit ecf53b1285
40 changed files with 161 additions and 111 deletions

View file

@ -11,11 +11,11 @@ import { leftPanelDisabled, moveAction,
addShortcut, registerShortcut, formFieldFocused
} from 'Common/Globals';
import { computedPaginatorHelper, showMessageComposer, populateMessageBody } from 'Common/UtilsUser';
import { computedPaginatorHelper, showMessageComposer, populateMessageBody, download } from 'Common/UtilsUser';
import { FileInfo } from 'Common/File';
import { isFullscreen, toggleFullscreen } from 'Common/Fullscreen';
import { mailBox } from 'Common/Links';
import { mailBox, attachmentDownload } from 'Common/Links';
import { Selector } from 'Common/Selector';
import { i18n } from 'Common/Translator';
@ -258,6 +258,7 @@ export class MailMessageList extends AbstractViewRight {
).throttle(50));
decorateKoCommands(this, {
downloadCommand: canBeMovedHelper,
forwardCommand: canBeMovedHelper,
deleteWithoutMoveCommand: canBeMovedHelper,
deleteCommand: canBeMovedHelper,
@ -290,6 +291,34 @@ export class MailMessageList extends AbstractViewRight {
]);
}
downloadCommand() {
let hashes = [];
MessagelistUserStore.forEach(message => {
if (message.checked()) {
message.attachments.forEach(attachment => {
if (!attachment.isLinked() && attachment.download) {
hashes.push(attachment.download);
}
});
}
});
if (hashes.length) {
Remote.post('AttachmentsActions', null, {
Do: 'Zip',
Hashes: hashes
})
.then(result => {
let hash = result?.Result?.FileHash;
if (hash) {
download(attachmentDownload(hash), hash+'.zip');
} else {
alert('Download failed');
}
})
.catch(() => alert('Download failed'));
}
}
deleteWithoutMoveCommand() {
SettingsCapa('DangerousActions')
&& moveMessagesToFolderType(FolderType.Trash, true);