mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Centralize current Folder checks to prevent bugs (which there were)
This commit is contained in:
parent
0c90875b61
commit
f451af2188
5 changed files with 46 additions and 80 deletions
|
|
@ -6,6 +6,7 @@ import { MessageSetAction } from 'Common/EnumsUser';
|
|||
import { $htmlCL } from 'Common/Globals';
|
||||
import { arrayLength, pInt, pString } from 'Common/Utils';
|
||||
import { addObservablesTo, addComputablesTo } from 'External/ko';
|
||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
|
||||
import {
|
||||
getFolderInboxName,
|
||||
|
|
@ -45,6 +46,7 @@ addObservablesTo(MessagelistUserStore, {
|
|||
page: 1,
|
||||
pageBeforeThread: 1,
|
||||
error: '',
|
||||
// Folder: '',
|
||||
|
||||
endHash: '',
|
||||
endThreadUid: 0,
|
||||
|
|
@ -68,6 +70,28 @@ addComputablesTo(MessagelistUserStore, {
|
|||
return value;
|
||||
},
|
||||
|
||||
isArchiveFolder: () => FolderUserStore.archiveFolder() === MessagelistUserStore().Folder,
|
||||
|
||||
isDraftFolder: () => FolderUserStore.draftsFolder() === MessagelistUserStore().Folder,
|
||||
|
||||
isSentFolder: () => FolderUserStore.sentFolder() === MessagelistUserStore().Folder,
|
||||
|
||||
isSpamFolder: () => FolderUserStore.spamFolder() === MessagelistUserStore().Folder,
|
||||
|
||||
isTrashFolder: () => FolderUserStore.trashFolder() === MessagelistUserStore().Folder,
|
||||
|
||||
archiveAllowed: () => ![UNUSED_OPTION_VALUE, MessagelistUserStore().Folder].includes(FolderUserStore.archiveFolder())
|
||||
&& !MessagelistUserStore.isDraftFolder(),
|
||||
|
||||
spamAllowed: () => !(UNUSED_OPTION_VALUE === FolderUserStore.spamFolder()
|
||||
// | MessagelistUserStore.isArchiveFolder()
|
||||
| MessagelistUserStore.isSentFolder()
|
||||
| MessagelistUserStore.isDraftFolder()),
|
||||
|
||||
isSpamAllowed: () => MessagelistUserStore.spamAllowed() && !MessagelistUserStore.isSpamFolder(),
|
||||
|
||||
isUnSpamAllowed: () => MessagelistUserStore.spamAllowed() && MessagelistUserStore.isSpamFolder(),
|
||||
|
||||
pageCount: () => Math.max(1, Math.ceil(MessagelistUserStore.count() / SettingsUserStore.messagesPerPage())),
|
||||
|
||||
mainSearch: {
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ import { Scope } from 'Common/Enums';
|
|||
|
||||
import { ComposeType, FolderType, MessageSetAction } from 'Common/EnumsUser';
|
||||
|
||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
|
||||
import { doc, leftPanelDisabled, moveAction,
|
||||
Settings, SettingsCapa, SettingsGet,
|
||||
addEventsListeners,
|
||||
|
|
@ -70,6 +68,9 @@ export class MailMessageList extends AbstractViewRight {
|
|||
this.allowDangerousActions = SettingsCapa('DangerousActions');
|
||||
|
||||
this.messageList = MessagelistUserStore;
|
||||
this.archiveAllowed = MessagelistUserStore.archiveAllowed;
|
||||
this.isSpamAllowed = MessagelistUserStore.isSpamAllowed;
|
||||
this.isUnSpamAllowed = MessagelistUserStore.isUnSpamAllowed;
|
||||
|
||||
this.composeInEdit = AppUserStore.composeInEdit;
|
||||
|
||||
|
|
@ -135,25 +136,6 @@ export class MailMessageList extends AbstractViewRight {
|
|||
return c && MessagelistUserStore().length > c;
|
||||
},
|
||||
|
||||
isSpamFolder: () => (FolderUserStore.spamFolder() || 0) === MessagelistUserStore().Folder,
|
||||
|
||||
isTrashFolder: () => (FolderUserStore.trashFolder() || 0) === MessagelistUserStore().Folder,
|
||||
|
||||
isDraftFolder: () => (FolderUserStore.draftsFolder() || 0) === MessagelistUserStore().Folder,
|
||||
|
||||
archiveAllowed: () =>
|
||||
(FolderUserStore.archiveFolder() || 0) !== MessagelistUserStore().Folder
|
||||
&& UNUSED_OPTION_VALUE !== FolderUserStore.archiveFolder()
|
||||
&& !this.isDraftFolder(),
|
||||
|
||||
spamAllowed: () => UNUSED_OPTION_VALUE !== FolderUserStore.spamFolder()
|
||||
&& (FolderUserStore.sentFolder() || 0) !== MessagelistUserStore().Folder
|
||||
&& !this.isDraftFolder(),
|
||||
|
||||
isSpamVisible: () => !this.isSpamFolder() && this.spamAllowed(),
|
||||
|
||||
isUnSpamVisible: () => this.isSpamFolder() && this.spamAllowed(),
|
||||
|
||||
mobileCheckedStateShow: () => ThemeStore.isMobile() ? MessagelistUserStore.listChecked().length : 1,
|
||||
|
||||
mobileCheckedStateHide: () => ThemeStore.isMobile() ? !MessagelistUserStore.listChecked().length : 1,
|
||||
|
|
@ -596,7 +578,7 @@ export class MailMessageList extends AbstractViewRight {
|
|||
!MessagelistUserStore.error() &&
|
||||
!MessagelistUserStore.endThreadUid() &&
|
||||
MessagelistUserStore().length &&
|
||||
(this.isSpamFolder() || this.isTrashFolder())
|
||||
(MessagelistUserStore.isSpamFolder() || MessagelistUserStore.isTrashFolder())
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
import ko from 'ko';
|
||||
import { koComputable } from 'External/ko';
|
||||
|
||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
|
||||
import { Scope } from 'Common/Enums';
|
||||
|
||||
|
|
@ -74,10 +71,10 @@ export class MailMessageView extends AbstractViewRight {
|
|||
*/
|
||||
createCommand = (fExecute, fCanExecute) => {
|
||||
let fResult = () => {
|
||||
fResult.canExecute() && fExecute.call(null);
|
||||
fCanExecute() && fExecute.call(null);
|
||||
return false;
|
||||
};
|
||||
fResult.canExecute = koComputable(() => fCanExecute());
|
||||
fResult.canExecute = fCanExecute;
|
||||
return fResult;
|
||||
},
|
||||
|
||||
|
|
@ -114,8 +111,13 @@ export class MailMessageView extends AbstractViewRight {
|
|||
const attachmentsActions = Settings.app('attachmentsActions');
|
||||
this.attachmentsActions = ko.observableArray(arrayLength(attachmentsActions) ? attachmentsActions : []);
|
||||
|
||||
this.message = MessageUserStore.message;
|
||||
this.hasCheckedMessages = MessagelistUserStore.hasCheckedMessages;
|
||||
this.isDraftFolder = MessagelistUserStore.isDraftFolder;
|
||||
this.archiveAllowed = MessagelistUserStore.archiveAllowed;
|
||||
this.isSpamAllowed = MessagelistUserStore.isSpamAllowed;
|
||||
this.isUnSpamAllowed = MessagelistUserStore.isUnSpamAllowed;
|
||||
|
||||
this.message = MessageUserStore.message;
|
||||
this.messageLoadingThrottle = MessageUserStore.loading;
|
||||
this.messagesBodiesDom = MessageUserStore.bodiesDom;
|
||||
this.messageError = MessageUserStore.error;
|
||||
|
|
@ -142,7 +144,7 @@ export class MailMessageView extends AbstractViewRight {
|
|||
|
||||
messageVisibility: () => !MessageUserStore.loading() && !!currentMessage(),
|
||||
|
||||
canBeRepliedOrForwarded: () => !this.isDraftFolder() && this.messageVisibility(),
|
||||
canBeRepliedOrForwarded: () => !MessagelistUserStore.isDraftFolder() && this.messageVisibility(),
|
||||
|
||||
viewFromDkimVisibility: () => 'none' !== this.viewFromDkimData()[0],
|
||||
|
||||
|
|
@ -441,53 +443,11 @@ export class MailMessageView extends AbstractViewRight {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isDraftFolder() {
|
||||
return currentMessage() && FolderUserStore.draftsFolder() === currentMessage().folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isSentFolder() {
|
||||
return currentMessage() && FolderUserStore.sentFolder() === currentMessage().folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isSpamFolder() {
|
||||
return currentMessage() && FolderUserStore.spamFolder() === currentMessage().folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isSpamDisabled() {
|
||||
return currentMessage() && FolderUserStore.spamFolder() === UNUSED_OPTION_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isArchiveFolder() {
|
||||
return currentMessage() && FolderUserStore.archiveFolder() === currentMessage().folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isArchiveDisabled() {
|
||||
return currentMessage() && FolderUserStore.archiveFolder() === UNUSED_OPTION_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isDraftOrSentFolder() {
|
||||
return this.isDraftFolder() || this.isSentFolder();
|
||||
return MessagelistUserStore.isDraftFolder() || MessagelistUserStore.isSentFolder();
|
||||
}
|
||||
|
||||
composeClick() {
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@
|
|||
<!-- /ko -->
|
||||
<div class="btn-group" data-bind="visible: mobileCheckedStateShow()">
|
||||
<a class="btn fontastic" data-bind="visible: archiveAllowed, command: archiveCommand" data-i18n="[title]GLOBAL/TO_ARCHIVE">🗄</a>
|
||||
<a class="btn fontastic" data-bind="visible: isSpamVisible, command: spamCommand" data-i18n="[title]GLOBAL/SPAM">⚠</a>
|
||||
<a class="btn" data-bind="visible: isUnSpamVisible, command: notSpamCommand" data-i18n="[title]GLOBAL/NOT_SPAM">
|
||||
<a class="btn fontastic" data-bind="visible: isSpamAllowed, command: spamCommand" data-i18n="[title]GLOBAL/SPAM">⚠</a>
|
||||
<a class="btn" data-bind="visible: isUnSpamAllowed, command: notSpamCommand" data-i18n="[title]GLOBAL/NOT_SPAM">
|
||||
<i class="icon-check-mark-circle-two"></i>
|
||||
</a>
|
||||
<a class="btn fontastic" data-bind="command: deleteCommand" data-i18n="[title]GLOBAL/DELETE">🗑</a>
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@
|
|||
<a class="btn btn-success buttonEdit fontastic" data-bind="command: messageEditCommand">🖉</a>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<a class="btn fontastic" data-bind="visible: !isDraftFolder() && !isArchiveFolder() && !isArchiveDisabled(), command: archiveCommand" data-i18n="[title]GLOBAL/TO_ARCHIVE">🗄</a>
|
||||
<a class="btn fontastic" data-bind="visible: !isDraftFolder() && !isSentFolder() && !isSpamFolder() && !isSpamDisabled(), command: spamCommand" data-i18n="[title]GLOBAL/SPAM">⚠</a>
|
||||
<a class="btn" data-bind="visible: !isDraftFolder() && !isSentFolder() && isSpamFolder() && !isSpamDisabled(), command: notSpamCommand" data-i18n="[title]GLOBAL/NOT_SPAM">
|
||||
<a class="btn fontastic" data-bind="visible: archiveAllowed, command: archiveCommand" data-i18n="[title]GLOBAL/TO_ARCHIVE">🗄</a>
|
||||
<a class="btn fontastic" data-bind="visible: isSpamAllowed , command: spamCommand" data-i18n="[title]GLOBAL/SPAM">⚠</a>
|
||||
<a class="btn" data-bind="visible: isUnSpamAllowed, command: notSpamCommand" data-i18n="[title]GLOBAL/NOT_SPAM">
|
||||
<i class="icon-check-mark-circle-two"></i>
|
||||
</a>
|
||||
<a class="btn fontastic" data-bind="command: deleteCommand" data-i18n="[title]GLOBAL/DELETE">🗑</a>
|
||||
|
|
@ -65,13 +65,13 @@
|
|||
</li>
|
||||
</div>
|
||||
<div class="dividerbar">
|
||||
<li role="presentation" data-bind="visible: !isDraftFolder() && !isArchiveFolder() && !isArchiveDisabled()">
|
||||
<li role="presentation" data-bind="visible: archiveAllowed">
|
||||
<a href="#" tabindex="-1" data-bind="command: archiveCommand" data-icon="🗄" data-i18n="GLOBAL/TO_ARCHIVE"></a>
|
||||
</li>
|
||||
<li role="presentation" data-bind="visible: !isDraftFolder() && !isSentFolder() && !isSpamFolder() && !isSpamDisabled()">
|
||||
<li role="presentation" data-bind="visible: isSpamAllowed">
|
||||
<a href="#" tabindex="-1" data-bind="command: spamCommand" data-icon="⚠" data-i18n="GLOBAL/SPAM"></a>
|
||||
</li>
|
||||
<li role="presentation" data-bind="visible: !isDraftFolder() && !isSentFolder() && isSpamFolder() && !isSpamDisabled()">
|
||||
<li role="presentation" data-bind="visible: isUnSpamAllowed">
|
||||
<a href="#" tabindex="-1" data-bind="command: notSpamCommand">
|
||||
<i class="icon-check-mark-circle-two"></i>
|
||||
<span data-i18n="GLOBAL/NOT_SPAM"></span>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue