mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
decorateKoCommands() each command must have function
And due to that, a bug is found and solved in MessageView
This commit is contained in:
parent
a67fb22bee
commit
f50f2c5ea0
5 changed files with 40 additions and 49 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import ko from 'ko';
|
||||
import { koComputable } from 'External/ko';
|
||||
|
||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
|
||||
|
|
@ -46,7 +47,7 @@ import * as Local from 'Storage/Client';
|
|||
|
||||
import Remote from 'Remote/User/Fetch';
|
||||
|
||||
import { decorateKoCommands, createCommand } from 'Knoin/Knoin';
|
||||
import { decorateKoCommands } from 'Knoin/Knoin';
|
||||
import { AbstractViewRight } from 'Knoin/AbstractViews';
|
||||
|
||||
import { PgpUserStore } from 'Stores/User/Pgp';
|
||||
|
|
@ -63,6 +64,20 @@ export class MailMessageView extends AbstractViewRight {
|
|||
super('MailMessageView');
|
||||
|
||||
const
|
||||
/**
|
||||
* @param {Function} fExecute
|
||||
* @param {(Function|boolean|null)=} fCanExecute = true
|
||||
* @returns {Function}
|
||||
*/
|
||||
createCommand = (fExecute, fCanExecute) => {
|
||||
let fResult = () => {
|
||||
fResult.canExecute() && fExecute.call(null);
|
||||
return false;
|
||||
};
|
||||
fResult.canExecute = koComputable(() => fCanExecute());
|
||||
return fResult;
|
||||
},
|
||||
|
||||
createCommandReplyHelper = type =>
|
||||
createCommand(() => this.replyOrforward(type), this.canBeRepliedOrForwarded),
|
||||
|
||||
|
|
@ -112,19 +127,6 @@ export class MailMessageView extends AbstractViewRight {
|
|||
|
||||
this.messageDomFocused = ko.observable(false).extend({ rateLimit: 0 });
|
||||
|
||||
// commands
|
||||
this.replyCommand = createCommandReplyHelper(ComposeType.Reply);
|
||||
this.replyAllCommand = createCommandReplyHelper(ComposeType.ReplyAll);
|
||||
this.forwardCommand = createCommandReplyHelper(ComposeType.Forward);
|
||||
this.forwardAsAttachmentCommand = createCommandReplyHelper(ComposeType.ForwardAsAttachment);
|
||||
this.editAsNewCommand = createCommandReplyHelper(ComposeType.EditAsNew);
|
||||
|
||||
this.deleteCommand = createCommandActionHelper(FolderType.Trash, true);
|
||||
this.deleteWithoutMoveCommand = createCommandActionHelper(FolderType.Trash, false);
|
||||
this.archiveCommand = createCommandActionHelper(FolderType.Archive, true);
|
||||
this.spamCommand = createCommandActionHelper(FolderType.Spam, true);
|
||||
this.notSpamCommand = createCommandActionHelper(FolderType.NotSpam, true);
|
||||
|
||||
// viewer
|
||||
this.viewHash = '';
|
||||
|
||||
|
|
@ -224,6 +226,19 @@ export class MailMessageView extends AbstractViewRight {
|
|||
|
||||
addEventListener('mailbox.message-view.toggle-full-screen', () => this.toggleFullScreen());
|
||||
|
||||
// commands
|
||||
this.replyCommand = createCommandReplyHelper(ComposeType.Reply);
|
||||
this.replyAllCommand = createCommandReplyHelper(ComposeType.ReplyAll);
|
||||
this.forwardCommand = createCommandReplyHelper(ComposeType.Forward);
|
||||
this.forwardAsAttachmentCommand = createCommandReplyHelper(ComposeType.ForwardAsAttachment);
|
||||
this.editAsNewCommand = createCommandReplyHelper(ComposeType.EditAsNew);
|
||||
|
||||
this.deleteCommand = createCommandActionHelper(FolderType.Trash, true);
|
||||
this.deleteWithoutMoveCommand = createCommandActionHelper(FolderType.Trash, false);
|
||||
this.archiveCommand = createCommandActionHelper(FolderType.Archive, true);
|
||||
this.spamCommand = createCommandActionHelper(FolderType.Spam, true);
|
||||
this.notSpamCommand = createCommandActionHelper(FolderType.NotSpam, true);
|
||||
|
||||
decorateKoCommands(this, {
|
||||
messageEditCommand: self => self.messageVisibility(),
|
||||
goUpCommand: self => !self.messageListOrViewLoading(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue