2016-08-17 06:01:20 +08:00
|
|
|
import ko from 'ko';
|
|
|
|
|
|
|
|
import {
|
2019-07-05 03:19:24 +08:00
|
|
|
Capa,
|
|
|
|
Layout,
|
|
|
|
Focused,
|
|
|
|
ComposeType,
|
|
|
|
FolderType,
|
|
|
|
MessageSetAction,
|
|
|
|
KeyState,
|
2016-08-17 06:01:20 +08:00
|
|
|
StorageResultType
|
|
|
|
} from 'Common/Enums';
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2020-09-30 18:31:34 +08:00
|
|
|
import { leftPanelDisabled, moveAction } from 'Common/Globals';
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2020-10-15 01:16:37 +08:00
|
|
|
import { computedPaginatorHelper } from 'Common/UtilsUser';
|
2020-10-03 20:02:33 +08:00
|
|
|
import { File } from 'Common/File';
|
2019-07-05 03:19:24 +08:00
|
|
|
|
|
|
|
import { mailBox, append } from 'Common/Links';
|
|
|
|
import { Selector } from 'Common/Selector';
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
import { i18n, initOnStartOrLangChange } from 'Common/Translator';
|
2016-08-17 06:01:20 +08:00
|
|
|
|
|
|
|
import {
|
2019-07-05 03:19:24 +08:00
|
|
|
getFolderFromCacheList,
|
|
|
|
clearMessageFlagsFromCacheByFolder,
|
|
|
|
hasRequestedMessage,
|
|
|
|
addRequestedMessage
|
2016-08-17 06:01:20 +08:00
|
|
|
} from 'Common/Cache';
|
|
|
|
|
|
|
|
import AppStore from 'Stores/User/App';
|
|
|
|
import QuotaStore from 'Stores/User/Quota';
|
|
|
|
import SettingsStore from 'Stores/User/Settings';
|
|
|
|
import FolderStore from 'Stores/User/Folder';
|
|
|
|
import MessageStore from 'Stores/User/Message';
|
|
|
|
|
2020-09-15 01:40:56 +08:00
|
|
|
import Remote from 'Remote/User/Fetch';
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2020-09-17 02:35:29 +08:00
|
|
|
import { view, command, ViewType, showScreenPopup, popupVisibility } from 'Knoin/Knoin';
|
2019-07-05 03:19:24 +08:00
|
|
|
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2020-08-07 22:28:30 +08:00
|
|
|
const
|
2020-09-04 18:05:17 +08:00
|
|
|
Settings = rl.settings,
|
2020-08-07 22:28:30 +08:00
|
|
|
canBeMovedHelper = (self) => self.canBeMoved(),
|
|
|
|
ifvisible = window.ifvisible;
|
2016-09-03 07:19:37 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
@view({
|
|
|
|
name: 'View/User/MailBox/MessageList',
|
|
|
|
type: ViewType.Right,
|
|
|
|
templateID: 'MailMessageList'
|
|
|
|
})
|
2019-07-05 03:19:24 +08:00
|
|
|
class MessageListMailBoxUserView extends AbstractViewNext {
|
2016-08-17 06:01:20 +08:00
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.sLastUid = null;
|
|
|
|
this.bPrefetch = false;
|
|
|
|
this.emptySubjectValue = '';
|
|
|
|
|
|
|
|
this.iGoToUpUpOrDownDownTimeout = 0;
|
|
|
|
|
2020-09-04 18:05:17 +08:00
|
|
|
this.mobile = !!Settings.app('mobile');
|
2020-10-13 01:46:41 +08:00
|
|
|
this.newMoveToFolder = !!Settings.get('NewMoveToFolder');
|
2016-08-17 06:01:20 +08:00
|
|
|
|
|
|
|
this.allowReload = !!Settings.capa(Capa.Reload);
|
|
|
|
this.allowSearch = !!Settings.capa(Capa.Search);
|
|
|
|
this.allowSearchAdv = !!Settings.capa(Capa.SearchAdv);
|
|
|
|
this.allowComposer = !!Settings.capa(Capa.Composer);
|
|
|
|
this.allowMessageListActions = !!Settings.capa(Capa.MessageListActions);
|
|
|
|
this.allowDangerousActions = !!Settings.capa(Capa.DangerousActions);
|
|
|
|
this.allowFolders = !!Settings.capa(Capa.Folders);
|
|
|
|
|
|
|
|
this.popupVisibility = popupVisibility;
|
|
|
|
|
|
|
|
this.message = MessageStore.message;
|
|
|
|
this.messageList = MessageStore.messageList;
|
|
|
|
this.messageListDisableAutoSelect = MessageStore.messageListDisableAutoSelect;
|
|
|
|
|
|
|
|
this.folderList = FolderStore.folderList;
|
|
|
|
|
|
|
|
this.composeInEdit = AppStore.composeInEdit;
|
|
|
|
this.leftPanelDisabled = leftPanelDisabled;
|
|
|
|
|
|
|
|
this.selectorMessageSelected = MessageStore.selectorMessageSelected;
|
|
|
|
this.selectorMessageFocused = MessageStore.selectorMessageFocused;
|
|
|
|
this.isMessageSelected = MessageStore.isMessageSelected;
|
|
|
|
this.messageListSearch = MessageStore.messageListSearch;
|
|
|
|
this.messageListThreadUid = MessageStore.messageListThreadUid;
|
|
|
|
this.messageListError = MessageStore.messageListError;
|
|
|
|
this.folderMenuForMove = FolderStore.folderMenuForMove;
|
|
|
|
|
|
|
|
this.useCheckboxesInList = SettingsStore.useCheckboxesInList;
|
|
|
|
|
|
|
|
this.mainMessageListSearch = MessageStore.mainMessageListSearch;
|
|
|
|
this.messageListEndFolder = MessageStore.messageListEndFolder;
|
|
|
|
this.messageListEndThreadUid = MessageStore.messageListEndThreadUid;
|
|
|
|
|
|
|
|
this.messageListCheckedOrSelected = MessageStore.messageListCheckedOrSelected;
|
|
|
|
this.messageListCheckedOrSelectedUidsWithSubMails = MessageStore.messageListCheckedOrSelectedUidsWithSubMails;
|
|
|
|
this.messageListCompleteLoadingThrottle = MessageStore.messageListCompleteLoadingThrottle;
|
|
|
|
this.messageListCompleteLoadingThrottleForAnimation = MessageStore.messageListCompleteLoadingThrottleForAnimation;
|
|
|
|
|
2020-09-03 18:51:15 +08:00
|
|
|
initOnStartOrLangChange(() => this.emptySubjectValue = i18n('MESSAGE_LIST/EMPTY_SUBJECT_TEXT'));
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.userQuota = QuotaStore.quota;
|
|
|
|
this.userUsageSize = QuotaStore.usage;
|
|
|
|
this.userUsageProc = QuotaStore.percentage;
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.moveDropdownTrigger = ko.observable(false);
|
|
|
|
this.moreDropdownTrigger = ko.observable(false);
|
|
|
|
|
|
|
|
// append drag and drop
|
2019-07-05 03:19:24 +08:00
|
|
|
this.dragOver = ko.observable(false).extend({ 'throttle': 1 });
|
|
|
|
this.dragOverEnter = ko.observable(false).extend({ 'throttle': 1 });
|
2016-08-17 06:01:20 +08:00
|
|
|
this.dragOverArea = ko.observable(null);
|
|
|
|
this.dragOverBodyArea = ko.observable(null);
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
this.messageListItemTemplate = ko.computed(() =>
|
|
|
|
this.mobile || Layout.SidePreview === SettingsStore.layout()
|
|
|
|
? 'MailMessageListItem'
|
|
|
|
: 'MailMessageListItemNoPreviewPane'
|
2016-08-17 06:01:20 +08:00
|
|
|
);
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.messageListSearchDesc = ko.computed(() => {
|
|
|
|
const value = MessageStore.messageListEndSearch();
|
2020-07-28 23:20:14 +08:00
|
|
|
return value ? i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', { 'SEARCH': value }) : '';
|
2016-08-17 06:01:20 +08:00
|
|
|
});
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2020-10-12 21:11:25 +08:00
|
|
|
this.messageListPaginator = ko.computed(
|
|
|
|
computedPaginatorHelper(MessageStore.messageListPage, MessageStore.messageListPageCount)
|
2019-07-05 03:19:24 +08:00
|
|
|
);
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.checkAll = ko.computed({
|
|
|
|
read: () => 0 < MessageStore.messageListChecked().length,
|
|
|
|
write: (value) => {
|
|
|
|
value = !!value;
|
2020-09-03 18:51:15 +08:00
|
|
|
MessageStore.messageList().forEach(message => message.checked(value));
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
});
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.inputMessageListSearchFocus = ko.observable(false);
|
|
|
|
|
|
|
|
this.sLastSearchValue = '';
|
|
|
|
this.inputProxyMessageListSearch = ko.computed({
|
|
|
|
read: this.mainMessageListSearch,
|
2020-09-03 18:51:15 +08:00
|
|
|
write: value => this.sLastSearchValue = value
|
2016-08-17 06:01:20 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
this.isIncompleteChecked = ko.computed(() => {
|
2020-07-28 18:35:41 +08:00
|
|
|
const c = MessageStore.messageListChecked().length;
|
|
|
|
return c && MessageStore.messageList().length > c;
|
2016-08-17 06:01:20 +08:00
|
|
|
});
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.hasMessages = ko.computed(() => 0 < this.messageList().length);
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.hasCheckedOrSelectedLines = ko.computed(() => 0 < this.messageListCheckedOrSelected().length);
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.isSpamFolder = ko.computed(
|
2020-07-28 23:20:14 +08:00
|
|
|
() => FolderStore.spamFolder() === this.messageListEndFolder() && FolderStore.spamFolder()
|
2016-08-17 06:01:20 +08:00
|
|
|
);
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.isSpamDisabled = ko.computed(() => UNUSED_OPTION_VALUE === FolderStore.spamFolder());
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.isTrashFolder = ko.computed(
|
2020-07-28 23:20:14 +08:00
|
|
|
() => FolderStore.trashFolder() === this.messageListEndFolder() && FolderStore.trashFolder()
|
2016-08-17 06:01:20 +08:00
|
|
|
);
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.isDraftFolder = ko.computed(
|
2020-07-28 23:20:14 +08:00
|
|
|
() => FolderStore.draftFolder() === this.messageListEndFolder() && FolderStore.draftFolder()
|
2016-08-17 06:01:20 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
this.isSentFolder = ko.computed(
|
2020-07-28 23:20:14 +08:00
|
|
|
() => FolderStore.sentFolder() === this.messageListEndFolder() && FolderStore.sentFolder()
|
2016-08-17 06:01:20 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
this.isArchiveFolder = ko.computed(
|
2020-07-28 23:20:14 +08:00
|
|
|
() => FolderStore.archiveFolder() === this.messageListEndFolder() && FolderStore.archiveFolder()
|
2016-08-17 06:01:20 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
this.isArchiveDisabled = ko.computed(() => UNUSED_OPTION_VALUE === FolderStore.archiveFolder());
|
|
|
|
|
|
|
|
this.isArchiveVisible = ko.computed(
|
|
|
|
() => !this.isArchiveFolder() && !this.isArchiveDisabled() && !this.isDraftFolder()
|
|
|
|
);
|
|
|
|
|
|
|
|
this.isSpamVisible = ko.computed(
|
|
|
|
() => !this.isSpamFolder() && !this.isSpamDisabled() && !this.isDraftFolder() && !this.isSentFolder()
|
|
|
|
);
|
|
|
|
|
|
|
|
this.isUnSpamVisible = ko.computed(
|
|
|
|
() => this.isSpamFolder() && !this.isSpamDisabled() && !this.isDraftFolder() && !this.isSentFolder()
|
|
|
|
);
|
|
|
|
|
2020-09-20 17:29:31 +08:00
|
|
|
// this.messageListChecked = MessageStore.messageListChecked;
|
|
|
|
this.mobileCheckedStateShow = ko.computed(() => this.mobile ? 0 < MessageStore.messageListChecked().length : true);
|
2016-06-16 07:36:44 +08:00
|
|
|
|
2020-09-20 17:29:31 +08:00
|
|
|
this.mobileCheckedStateHide = ko.computed(() => this.mobile ? !MessageStore.messageListChecked().length : true);
|
2015-07-07 02:46:44 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.messageListFocused = ko.computed(() => Focused.MessageList === AppStore.focusedState());
|
|
|
|
|
|
|
|
this.canBeMoved = this.hasCheckedOrSelectedLines;
|
|
|
|
|
2020-07-20 21:47:33 +08:00
|
|
|
this.quotaTooltip = this.quotaTooltip.bind(this);
|
2016-05-01 09:07:10 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.selector = new Selector(
|
2019-07-05 03:19:24 +08:00
|
|
|
this.messageList,
|
|
|
|
this.selectorMessageSelected,
|
|
|
|
this.selectorMessageFocused,
|
|
|
|
'.messageListItem .actionHandle',
|
|
|
|
'.messageListItem.selected',
|
|
|
|
'.messageListItem .checkboxMessage',
|
|
|
|
'.messageListItem.focused'
|
|
|
|
);
|
2016-05-01 09:07:10 +08:00
|
|
|
|
2020-09-03 18:51:15 +08:00
|
|
|
this.selector.on('onItemSelect', message => MessageStore.selectMessage(message));
|
2016-05-01 09:07:10 +08:00
|
|
|
|
2020-09-03 18:51:15 +08:00
|
|
|
this.selector.on('onItemGetUid', message => (message ? message.generateUid() : ''));
|
2016-05-01 09:07:10 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.selector.on('onAutoSelect', () => this.useAutoSelect());
|
2015-04-02 02:18:15 +08:00
|
|
|
|
2020-09-03 18:51:15 +08:00
|
|
|
this.selector.on('onUpUpOrDownDown', v => this.goToUpUpOrDownDown(v));
|
2015-05-03 04:22:32 +08:00
|
|
|
|
2020-09-03 18:51:15 +08:00
|
|
|
addEventListener('mailbox.message-list.selector.go-down', e => this.selector.goDown(e.detail));
|
2015-04-02 02:18:15 +08:00
|
|
|
|
2020-09-03 18:51:15 +08:00
|
|
|
addEventListener('mailbox.message-list.selector.go-up', e => this.selector.goUp(e.detail));
|
2015-04-02 02:18:15 +08:00
|
|
|
|
2020-08-15 02:35:39 +08:00
|
|
|
addEventListener('mailbox.message.show', e => {
|
|
|
|
const sFolder = e.detail.Folder, sUid = e.detail.Uid;
|
|
|
|
|
2020-07-22 16:43:19 +08:00
|
|
|
const message = this.messageList().find(
|
2020-10-23 21:15:54 +08:00
|
|
|
item => item && sFolder === item.folder && sUid === item.uid
|
2019-07-05 03:19:24 +08:00
|
|
|
);
|
2015-04-02 02:18:15 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if ('INBOX' === sFolder) {
|
2020-09-17 02:35:29 +08:00
|
|
|
rl.route.setHash(mailBox(sFolder, 1));
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2015-04-02 02:18:15 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (message) {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.selector.selectMessageItem(message);
|
2019-07-05 03:19:24 +08:00
|
|
|
} else {
|
|
|
|
if ('INBOX' !== sFolder) {
|
2020-09-17 02:35:29 +08:00
|
|
|
rl.route.setHash(mailBox(sFolder, 1));
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2015-04-02 02:18:15 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
MessageStore.selectMessageByFolderAndUid(sFolder, sUid);
|
2015-04-02 02:18:15 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
});
|
2015-04-02 02:18:15 +08:00
|
|
|
|
2020-08-27 21:45:47 +08:00
|
|
|
MessageStore.messageListEndHash.subscribe((() =>
|
|
|
|
this.selector.scrollToFocused()
|
|
|
|
).throttle(50));
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2015-02-25 23:29:34 +08:00
|
|
|
|
2016-09-03 07:19:37 +08:00
|
|
|
@command()
|
|
|
|
clearCommand() {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.DangerousActions)) {
|
2016-09-03 07:19:37 +08:00
|
|
|
showScreenPopup(require('View/Popup/FolderClear'), [FolderStore.currentFolder()]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@command()
|
|
|
|
reloadCommand() {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (!MessageStore.messageListCompleteLoadingThrottleForAnimation() && this.allowReload) {
|
2020-09-15 15:29:25 +08:00
|
|
|
rl.app.reloadMessageList(false, true);
|
2016-09-03 07:19:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@command(canBeMovedHelper)
|
|
|
|
multyForwardCommand() {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.Composer)) {
|
2016-09-03 07:19:37 +08:00
|
|
|
showScreenPopup(require('View/Popup/Compose'), [
|
2019-07-05 03:19:24 +08:00
|
|
|
ComposeType.ForwardAsAttachment,
|
|
|
|
MessageStore.messageListCheckedOrSelected()
|
|
|
|
]);
|
2016-09-03 07:19:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@command(canBeMovedHelper)
|
|
|
|
deleteWithoutMoveCommand() {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.DangerousActions)) {
|
2020-09-15 15:29:25 +08:00
|
|
|
rl.app.deleteMessagesFromFolder(
|
2019-07-05 03:19:24 +08:00
|
|
|
FolderType.Trash,
|
2016-09-03 07:19:37 +08:00
|
|
|
FolderStore.currentFolderFullNameRaw(),
|
2019-07-05 03:19:24 +08:00
|
|
|
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(),
|
|
|
|
false
|
|
|
|
);
|
2016-09-03 07:19:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@command(canBeMovedHelper)
|
|
|
|
deleteCommand() {
|
2020-09-15 15:29:25 +08:00
|
|
|
rl.app.deleteMessagesFromFolder(
|
2019-07-05 03:19:24 +08:00
|
|
|
FolderType.Trash,
|
2016-09-03 07:19:37 +08:00
|
|
|
FolderStore.currentFolderFullNameRaw(),
|
2019-07-05 03:19:24 +08:00
|
|
|
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(),
|
|
|
|
true
|
|
|
|
);
|
2016-09-03 07:19:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@command(canBeMovedHelper)
|
|
|
|
archiveCommand() {
|
2020-09-15 15:29:25 +08:00
|
|
|
rl.app.deleteMessagesFromFolder(
|
2019-07-05 03:19:24 +08:00
|
|
|
FolderType.Archive,
|
2016-09-03 07:19:37 +08:00
|
|
|
FolderStore.currentFolderFullNameRaw(),
|
2019-07-05 03:19:24 +08:00
|
|
|
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(),
|
|
|
|
true
|
|
|
|
);
|
2016-09-03 07:19:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@command(canBeMovedHelper)
|
|
|
|
spamCommand() {
|
2020-09-15 15:29:25 +08:00
|
|
|
rl.app.deleteMessagesFromFolder(
|
2019-07-05 03:19:24 +08:00
|
|
|
FolderType.Spam,
|
2016-09-03 07:19:37 +08:00
|
|
|
FolderStore.currentFolderFullNameRaw(),
|
2019-07-05 03:19:24 +08:00
|
|
|
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(),
|
|
|
|
true
|
|
|
|
);
|
2016-09-03 07:19:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@command(canBeMovedHelper)
|
|
|
|
notSpamCommand() {
|
2020-09-15 15:29:25 +08:00
|
|
|
rl.app.deleteMessagesFromFolder(
|
2019-07-05 03:19:24 +08:00
|
|
|
FolderType.NotSpam,
|
2016-09-03 07:19:37 +08:00
|
|
|
FolderStore.currentFolderFullNameRaw(),
|
2019-07-05 03:19:24 +08:00
|
|
|
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(),
|
|
|
|
true
|
|
|
|
);
|
2016-09-03 07:19:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@command(canBeMovedHelper)
|
|
|
|
moveCommand() {} // eslint-disable-line no-empty-function
|
|
|
|
|
2017-02-09 01:48:53 +08:00
|
|
|
@command(canBeMovedHelper)
|
|
|
|
moveNewCommand(vm, event) {
|
2020-10-13 01:46:41 +08:00
|
|
|
if (this.newMoveToFolder && this.mobileCheckedStateShow()) {
|
2017-02-09 01:48:53 +08:00
|
|
|
if (vm && event && event.preventDefault) {
|
|
|
|
event.preventDefault();
|
2020-09-30 20:07:03 +08:00
|
|
|
event.stopPropagation();
|
2017-02-09 01:48:53 +08:00
|
|
|
}
|
|
|
|
|
2020-09-30 20:07:03 +08:00
|
|
|
let b = moveAction();
|
|
|
|
AppStore.focusedState(b ? Focused.MessageList : Focused.FolderList);
|
|
|
|
moveAction(!b);
|
2017-02-09 01:48:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-03 07:19:37 +08:00
|
|
|
hideLeft(item, event) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2015-02-25 23:29:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
leftPanelDisabled(true);
|
|
|
|
}
|
2016-07-01 06:50:11 +08:00
|
|
|
|
2016-09-03 07:19:37 +08:00
|
|
|
showLeft(item, event) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
leftPanelDisabled(false);
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
composeClick() {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.Composer)) {
|
2016-08-17 06:01:20 +08:00
|
|
|
showScreenPopup(require('View/Popup/Compose'));
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
goToUpUpOrDownDown(up) {
|
2020-09-20 17:29:31 +08:00
|
|
|
if (MessageStore.messageListChecked().length) {
|
2016-08-17 06:01:20 +08:00
|
|
|
return false;
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2020-08-12 06:25:36 +08:00
|
|
|
clearTimeout(this.iGoToUpUpOrDownDownTimeout);
|
2020-07-30 03:49:41 +08:00
|
|
|
this.iGoToUpUpOrDownDownTimeout = setTimeout(() => {
|
2020-09-30 20:07:03 +08:00
|
|
|
let prev, next, temp, current;
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2020-10-12 21:11:25 +08:00
|
|
|
this.messageListPaginator().find(item => {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (item) {
|
|
|
|
if (current) {
|
2016-08-17 06:01:20 +08:00
|
|
|
next = item;
|
2014-08-21 23:08:34 +08:00
|
|
|
}
|
2014-04-09 04:59:22 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (item.current) {
|
2016-08-17 06:01:20 +08:00
|
|
|
current = item;
|
|
|
|
prev = temp;
|
2014-08-21 23:08:34 +08:00
|
|
|
}
|
2014-04-09 04:59:22 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (next) {
|
2016-08-17 06:01:20 +08:00
|
|
|
return true;
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
temp = item;
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
return false;
|
|
|
|
});
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Layout.NoPreview === SettingsStore.layout() && !this.message()) {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.selector.iFocusedNextHelper = up ? -1 : 1;
|
2019-07-05 03:19:24 +08:00
|
|
|
} else {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.selector.iSelectNextHelper = up ? -1 : 1;
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (up ? prev : next) {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.selector.unselect();
|
|
|
|
this.gotoPage(up ? prev : next);
|
|
|
|
}
|
2020-08-14 04:58:41 +08:00
|
|
|
}, 350);
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
return true;
|
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
useAutoSelect() {
|
2020-09-30 20:07:03 +08:00
|
|
|
return !this.messageListDisableAutoSelect()
|
|
|
|
&& !/is:unseen/.test(this.mainMessageListSearch())
|
|
|
|
&& Layout.NoPreview !== SettingsStore.layout();
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2016-08-10 03:52:30 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
searchEnterAction() {
|
|
|
|
this.mainMessageListSearch(this.sLastSearchValue);
|
|
|
|
this.inputMessageListSearchFocus(false);
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
/**
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
printableMessageCountForDeletion() {
|
|
|
|
const cnt = this.messageListCheckedOrSelectedUidsWithSubMails().length;
|
|
|
|
return 1 < cnt ? ' (' + (100 > cnt ? cnt : '99+') + ')' : ''; // eslint-disable-line no-magic-numbers
|
|
|
|
}
|
2016-08-10 03:52:30 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
cancelSearch() {
|
|
|
|
this.mainMessageListSearch('');
|
|
|
|
this.inputMessageListSearchFocus(false);
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2015-04-21 06:39:14 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
cancelThreadUid() {
|
2020-09-17 02:35:29 +08:00
|
|
|
rl.route.setHash(
|
2019-07-05 03:19:24 +08:00
|
|
|
mailBox(
|
|
|
|
FolderStore.currentFolderFullNameHash(),
|
|
|
|
MessageStore.messageListPageBeforeThread(),
|
|
|
|
MessageStore.messageListSearch()
|
|
|
|
)
|
|
|
|
);
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2015-04-23 05:33:02 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
/**
|
|
|
|
* @param {string} sToFolderFullNameRaw
|
|
|
|
* @param {boolean} bCopy
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
moveSelectedMessagesToFolder(sToFolderFullNameRaw, bCopy) {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (this.canBeMoved()) {
|
2020-09-15 15:29:25 +08:00
|
|
|
rl.app.moveMessagesToFolder(
|
2016-08-17 06:01:20 +08:00
|
|
|
FolderStore.currentFolderFullNameRaw(),
|
2019-07-05 03:19:24 +08:00
|
|
|
MessageStore.messageListCheckedOrSelectedUidsWithSubMails(),
|
|
|
|
sToFolderFullNameRaw,
|
|
|
|
bCopy
|
|
|
|
);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2014-01-26 22:23:37 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
return false;
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2014-01-26 22:23:37 +08:00
|
|
|
|
2020-09-23 16:08:34 +08:00
|
|
|
getDragData(event) {
|
2020-09-18 20:01:27 +08:00
|
|
|
const item = ko.dataFor(document.elementFromPoint(event.clientX, event.clientY));
|
2020-09-23 16:08:34 +08:00
|
|
|
item && item.checked && item.checked(true);
|
2020-09-18 20:01:27 +08:00
|
|
|
const uids = MessageStore.messageListCheckedOrSelectedUidsWithSubMails();
|
2020-09-20 17:29:31 +08:00
|
|
|
item && !uids.includes(item.uid) && uids.push(item.uid);
|
2020-09-23 16:08:34 +08:00
|
|
|
return uids.length ? {
|
|
|
|
copy: event.ctrlKey,
|
|
|
|
folder: FolderStore.currentFolderFullNameRaw(),
|
|
|
|
uids: uids
|
|
|
|
} : null;
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2014-05-27 20:54:41 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
/**
|
|
|
|
* @param {string} sFolderFullNameRaw
|
|
|
|
* @param {number} iSetAction
|
|
|
|
* @param {Array=} aMessages = null
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2016-12-15 05:56:17 +08:00
|
|
|
setAction(sFolderFullNameRaw, iSetAction, aMessages) {
|
2020-09-15 15:29:25 +08:00
|
|
|
rl.app.messageListAction(sFolderFullNameRaw, iSetAction, aMessages);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} sFolderFullNameRaw
|
|
|
|
* @param {number} iSetAction
|
2016-12-15 05:56:17 +08:00
|
|
|
* @param {string} sThreadUid = ''
|
2016-08-17 06:01:20 +08:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
2016-12-15 05:56:17 +08:00
|
|
|
setActionForAll(sFolderFullNameRaw, iSetAction, sThreadUid = '') {
|
2020-07-28 23:20:14 +08:00
|
|
|
if (sFolderFullNameRaw) {
|
2016-12-15 05:56:17 +08:00
|
|
|
let cnt = 0;
|
|
|
|
const uids = [];
|
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
let folder = getFolderFromCacheList(sFolderFullNameRaw);
|
2019-07-05 03:19:24 +08:00
|
|
|
if (folder) {
|
|
|
|
switch (iSetAction) {
|
2016-08-17 06:01:20 +08:00
|
|
|
case MessageSetAction.SetSeen:
|
|
|
|
folder = getFolderFromCacheList(sFolderFullNameRaw);
|
2019-07-05 03:19:24 +08:00
|
|
|
if (folder) {
|
2020-07-22 20:49:18 +08:00
|
|
|
MessageStore.messageList().forEach(message => {
|
2020-10-23 21:15:54 +08:00
|
|
|
if (message.isUnseen()) {
|
2020-09-20 17:29:31 +08:00
|
|
|
++cnt;
|
2016-12-15 05:56:17 +08:00
|
|
|
}
|
|
|
|
|
2020-10-23 21:15:54 +08:00
|
|
|
message.isUnseen(false);
|
2016-12-15 05:56:17 +08:00
|
|
|
uids.push(message.uid);
|
2016-08-17 06:01:20 +08:00
|
|
|
});
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (sThreadUid) {
|
2016-12-15 05:56:17 +08:00
|
|
|
folder.messageCountUnread(folder.messageCountUnread() - cnt);
|
2019-07-05 03:19:24 +08:00
|
|
|
if (0 > folder.messageCountUnread()) {
|
2016-12-15 05:56:17 +08:00
|
|
|
folder.messageCountUnread(0);
|
|
|
|
}
|
2019-07-05 03:19:24 +08:00
|
|
|
} else {
|
2016-12-15 05:56:17 +08:00
|
|
|
folder.messageCountUnread(0);
|
|
|
|
}
|
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
clearMessageFlagsFromCacheByFolder(sFolderFullNameRaw);
|
|
|
|
}
|
|
|
|
|
2020-07-30 03:49:41 +08:00
|
|
|
Remote.messageSetSeenToAll(()=>{}, sFolderFullNameRaw, true, sThreadUid ? uids : null);
|
2016-08-17 06:01:20 +08:00
|
|
|
break;
|
|
|
|
case MessageSetAction.UnsetSeen:
|
|
|
|
folder = getFolderFromCacheList(sFolderFullNameRaw);
|
2019-07-05 03:19:24 +08:00
|
|
|
if (folder) {
|
2020-07-22 20:49:18 +08:00
|
|
|
MessageStore.messageList().forEach(message => {
|
2020-10-23 21:15:54 +08:00
|
|
|
if (!message.isUnseen()) {
|
2020-09-20 17:29:31 +08:00
|
|
|
++cnt;
|
2016-12-15 05:56:17 +08:00
|
|
|
}
|
|
|
|
|
2020-10-23 21:15:54 +08:00
|
|
|
message.isUnseen(true);
|
2016-12-15 05:56:17 +08:00
|
|
|
uids.push(message.uid);
|
2016-08-17 06:01:20 +08:00
|
|
|
});
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (sThreadUid) {
|
2016-12-15 05:56:17 +08:00
|
|
|
folder.messageCountUnread(folder.messageCountUnread() + cnt);
|
2019-07-05 03:19:24 +08:00
|
|
|
if (folder.messageCountAll() < folder.messageCountUnread()) {
|
2016-12-15 05:56:17 +08:00
|
|
|
folder.messageCountUnread(folder.messageCountAll());
|
|
|
|
}
|
2019-07-05 03:19:24 +08:00
|
|
|
} else {
|
2016-12-15 05:56:17 +08:00
|
|
|
folder.messageCountUnread(folder.messageCountAll());
|
|
|
|
}
|
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
clearMessageFlagsFromCacheByFolder(sFolderFullNameRaw);
|
|
|
|
}
|
2016-12-15 05:56:17 +08:00
|
|
|
|
2020-07-30 03:49:41 +08:00
|
|
|
Remote.messageSetSeenToAll(()=>{}, sFolderFullNameRaw, false, sThreadUid ? uids : null);
|
2016-08-17 06:01:20 +08:00
|
|
|
break;
|
|
|
|
// no default
|
|
|
|
}
|
|
|
|
|
2020-09-15 15:29:25 +08:00
|
|
|
rl.app.reloadFlagsCurrentMessageListAndMessageFromCache();
|
2015-02-25 23:29:34 +08:00
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
}
|
2015-02-25 23:29:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
listSetSeen() {
|
2019-07-05 03:19:24 +08:00
|
|
|
this.setAction(
|
|
|
|
FolderStore.currentFolderFullNameRaw(),
|
|
|
|
MessageSetAction.SetSeen,
|
|
|
|
MessageStore.messageListCheckedOrSelected()
|
|
|
|
);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2014-04-08 05:03:58 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
listSetAllSeen() {
|
2019-07-05 03:19:24 +08:00
|
|
|
this.setActionForAll(
|
|
|
|
FolderStore.currentFolderFullNameRaw(),
|
|
|
|
MessageSetAction.SetSeen,
|
|
|
|
this.messageListEndThreadUid()
|
|
|
|
);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2015-05-20 06:05:54 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
listUnsetSeen() {
|
2019-07-05 03:19:24 +08:00
|
|
|
this.setAction(
|
|
|
|
FolderStore.currentFolderFullNameRaw(),
|
|
|
|
MessageSetAction.UnsetSeen,
|
|
|
|
MessageStore.messageListCheckedOrSelected()
|
|
|
|
);
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2014-04-09 04:59:22 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
listSetFlags() {
|
2019-07-05 03:19:24 +08:00
|
|
|
this.setAction(
|
|
|
|
FolderStore.currentFolderFullNameRaw(),
|
|
|
|
MessageSetAction.SetFlag,
|
|
|
|
MessageStore.messageListCheckedOrSelected()
|
|
|
|
);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
listUnsetFlags() {
|
2019-07-05 03:19:24 +08:00
|
|
|
this.setAction(
|
|
|
|
FolderStore.currentFolderFullNameRaw(),
|
|
|
|
MessageSetAction.UnsetFlag,
|
|
|
|
MessageStore.messageListCheckedOrSelected()
|
|
|
|
);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
flagMessages(currentMessage) {
|
|
|
|
const checked = this.messageListCheckedOrSelected();
|
2019-07-05 03:19:24 +08:00
|
|
|
if (currentMessage) {
|
2020-07-23 02:09:31 +08:00
|
|
|
const checkedUids = checked.map(message => message.uid);
|
2020-07-28 18:35:41 +08:00
|
|
|
if (checkedUids.includes(currentMessage.uid)) {
|
2019-07-05 03:19:24 +08:00
|
|
|
this.setAction(
|
2020-10-23 21:15:54 +08:00
|
|
|
currentMessage.folder,
|
|
|
|
currentMessage.isFlagged() ? MessageSetAction.UnsetFlag : MessageSetAction.SetFlag,
|
2019-07-05 03:19:24 +08:00
|
|
|
checked
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.setAction(
|
2020-10-23 21:15:54 +08:00
|
|
|
currentMessage.folder,
|
|
|
|
currentMessage.isFlagged() ? MessageSetAction.UnsetFlag : MessageSetAction.SetFlag,
|
2019-07-05 03:19:24 +08:00
|
|
|
[currentMessage]
|
|
|
|
);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2015-05-20 06:05:54 +08:00
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2016-07-01 06:50:11 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
flagMessagesFast(bFlag) {
|
|
|
|
const checked = this.messageListCheckedOrSelected();
|
2020-07-28 18:35:41 +08:00
|
|
|
if (checked.length) {
|
2020-07-30 03:49:41 +08:00
|
|
|
if (undefined === bFlag) {
|
2020-10-23 21:15:54 +08:00
|
|
|
const flagged = checked.filter(message => message.isFlagged());
|
2019-07-05 03:19:24 +08:00
|
|
|
this.setAction(
|
2020-10-23 21:15:54 +08:00
|
|
|
checked[0].folder,
|
2019-07-05 03:19:24 +08:00
|
|
|
checked.length === flagged.length ? MessageSetAction.UnsetFlag : MessageSetAction.SetFlag,
|
|
|
|
checked
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.setAction(
|
2020-10-23 21:15:54 +08:00
|
|
|
checked[0].folder,
|
2019-07-05 03:19:24 +08:00
|
|
|
!bFlag ? MessageSetAction.UnsetFlag : MessageSetAction.SetFlag,
|
|
|
|
checked
|
|
|
|
);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2014-04-08 05:03:58 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
seenMessagesFast(seen) {
|
|
|
|
const checked = this.messageListCheckedOrSelected();
|
2020-07-28 18:35:41 +08:00
|
|
|
if (checked.length) {
|
2020-07-30 03:49:41 +08:00
|
|
|
if (undefined === seen) {
|
2020-10-23 21:15:54 +08:00
|
|
|
const unseen = checked.filter(message => message.isUnseen());
|
2019-07-05 03:19:24 +08:00
|
|
|
this.setAction(
|
2020-10-23 21:15:54 +08:00
|
|
|
checked[0].folder,
|
2020-07-28 18:35:41 +08:00
|
|
|
unseen.length ? MessageSetAction.SetSeen : MessageSetAction.UnsetSeen,
|
2019-07-05 03:19:24 +08:00
|
|
|
checked
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.setAction(
|
2020-10-23 21:15:54 +08:00
|
|
|
checked[0].folder,
|
2019-07-05 03:19:24 +08:00
|
|
|
seen ? MessageSetAction.SetSeen : MessageSetAction.UnsetSeen,
|
|
|
|
checked
|
|
|
|
);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2015-04-21 06:39:14 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
gotoPage(page) {
|
2020-09-17 02:35:29 +08:00
|
|
|
page && rl.route.setHash(
|
2020-09-03 18:51:15 +08:00
|
|
|
mailBox(
|
|
|
|
FolderStore.currentFolderFullNameHash(),
|
|
|
|
page.value,
|
|
|
|
MessageStore.messageListSearch(),
|
|
|
|
MessageStore.messageListThreadUid()
|
|
|
|
)
|
|
|
|
);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2015-04-21 06:39:14 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
gotoThread(message) {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (message && 0 < message.threadsLen()) {
|
2016-08-17 06:01:20 +08:00
|
|
|
MessageStore.messageListPageBeforeThread(MessageStore.messageListPage());
|
|
|
|
|
2020-09-17 02:35:29 +08:00
|
|
|
rl.route.setHash(
|
|
|
|
mailBox(FolderStore.currentFolderFullNameHash(), 1, MessageStore.messageListSearch(), message.uid)
|
|
|
|
);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2015-04-21 06:39:14 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
clearListIsVisible() {
|
2019-07-05 03:19:24 +08:00
|
|
|
return (
|
2020-07-28 23:20:14 +08:00
|
|
|
!this.messageListSearchDesc() &&
|
|
|
|
!this.messageListError() &&
|
|
|
|
!this.messageListEndThreadUid() &&
|
2020-07-28 18:35:41 +08:00
|
|
|
this.messageList().length &&
|
2019-07-05 03:19:24 +08:00
|
|
|
(this.isSpamFolder() || this.isTrashFolder())
|
|
|
|
);
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2015-04-21 06:39:14 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
onBuild(dom) {
|
2020-08-30 16:30:50 +08:00
|
|
|
const eqs = (ev, s) => ev.target.closestWithin(s, dom);
|
2014-04-08 05:03:58 +08:00
|
|
|
|
2020-08-30 16:30:50 +08:00
|
|
|
this.selector.init(dom.querySelector('.b-content'), KeyState.MessageList);
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2020-08-30 16:30:50 +08:00
|
|
|
dom.addEventListener('click', event => {
|
|
|
|
this.mobile && leftPanelDisabled(true);
|
2014-04-08 05:03:58 +08:00
|
|
|
|
2020-08-30 16:30:50 +08:00
|
|
|
if (eqs(event, '.messageList .b-message-list-wrapper') && Focused.MessageView === AppStore.focusedState()) {
|
|
|
|
AppStore.focusedState(Focused.MessageList);
|
|
|
|
}
|
|
|
|
|
2020-10-12 21:11:25 +08:00
|
|
|
let el = eqs(event, '.e-paginator .e-page');
|
2020-08-30 16:30:50 +08:00
|
|
|
el && this.gotoPage(ko.dataFor(el));
|
|
|
|
|
|
|
|
eqs(event, '.messageList .checkboxCkeckAll') && this.checkAll(!this.checkAll());
|
|
|
|
|
|
|
|
el = eqs(event, '.messageList .messageListItem .flagParent');
|
|
|
|
el && this.flagMessages(ko.dataFor(el));
|
|
|
|
|
|
|
|
el = eqs(event, '.messageList .messageListItem .threads-len');
|
|
|
|
el && this.gotoThread(ko.dataFor(el));
|
|
|
|
});
|
|
|
|
|
|
|
|
dom.addEventListener('dblclick', event => {
|
|
|
|
let el = eqs(event, '.messageList .messageListItem .actionHandle');
|
|
|
|
el && this.gotoThread(ko.dataFor(el));
|
|
|
|
});
|
2014-04-08 05:03:58 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.initUploaderForAppend();
|
|
|
|
this.initShortcuts();
|
2014-06-03 07:22:36 +08:00
|
|
|
|
2020-09-30 18:31:34 +08:00
|
|
|
if (ifvisible && !rl.settings.app('mobile') && Settings.capa(Capa.Prefetch)) {
|
2020-08-14 04:58:41 +08:00
|
|
|
ifvisible.idle(this.prefetchNextTick.bind(this));
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
initShortcuts() {
|
2020-10-09 16:31:44 +08:00
|
|
|
shortcuts.add('enter,open', '', KeyState.MessageList, () => {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (this.message() && this.useAutoSelect()) {
|
2020-08-15 02:35:39 +08:00
|
|
|
dispatchEvent(new CustomEvent('mailbox.message-view.toggle-full-screen'));
|
2016-08-17 06:01:20 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2016-06-30 08:02:45 +08:00
|
|
|
});
|
2014-01-26 22:23:37 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.MessageListActions)) {
|
2016-08-17 06:01:20 +08:00
|
|
|
// archive (zip)
|
2020-09-26 06:02:29 +08:00
|
|
|
shortcuts.add('z', '', [KeyState.MessageList, KeyState.MessageView], () => {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.archiveCommand();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
// delete
|
2020-09-26 06:02:29 +08:00
|
|
|
shortcuts.add('delete', 'shift', KeyState.MessageList, () => {
|
|
|
|
MessageStore.messageListCheckedOrSelected().length && this.deleteWithoutMoveCommand();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
// shortcuts.add('3', 'shift', KeyState.MessageList, () => {
|
|
|
|
shortcuts.add('delete', '', KeyState.MessageList, () => {
|
|
|
|
MessageStore.messageListCheckedOrSelected().length && this.deleteCommand();
|
|
|
|
return false;
|
2016-08-17 06:01:20 +08:00
|
|
|
});
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.Reload)) {
|
2016-08-17 06:01:20 +08:00
|
|
|
// check mail
|
2020-09-26 06:02:29 +08:00
|
|
|
shortcuts.add('r', 'meta', [KeyState.FolderList, KeyState.MessageList, KeyState.MessageView], () => {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.reloadCommand();
|
|
|
|
return false;
|
|
|
|
});
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2016-07-01 06:50:11 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
// check all
|
2020-09-26 06:02:29 +08:00
|
|
|
shortcuts.add('a', 'meta', KeyState.MessageList, () => {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.checkAll(!(this.checkAll() && !this.isIncompleteChecked()));
|
|
|
|
return false;
|
|
|
|
});
|
2014-06-03 07:22:36 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.Composer)) {
|
2016-08-17 06:01:20 +08:00
|
|
|
// write/compose (open compose popup)
|
2020-10-09 16:31:44 +08:00
|
|
|
shortcuts.add('w,c,new', '', [KeyState.MessageList, KeyState.MessageView], () => {
|
2016-08-17 06:01:20 +08:00
|
|
|
showScreenPopup(require('View/Popup/Compose'));
|
|
|
|
return false;
|
|
|
|
});
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.MessageListActions)) {
|
2016-08-17 06:01:20 +08:00
|
|
|
// important - star/flag messages
|
2020-09-26 06:02:29 +08:00
|
|
|
shortcuts.add('i', '', [KeyState.MessageList, KeyState.MessageView], () => {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.flagMessagesFast();
|
|
|
|
return false;
|
|
|
|
});
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2014-06-03 07:22:36 +08:00
|
|
|
|
2020-09-26 06:02:29 +08:00
|
|
|
shortcuts.add('t', '', [KeyState.MessageList], () => {
|
2016-08-17 06:01:20 +08:00
|
|
|
let message = this.selectorMessageSelected();
|
2019-07-05 03:19:24 +08:00
|
|
|
if (!message) {
|
2016-08-17 06:01:20 +08:00
|
|
|
message = this.selectorMessageFocused();
|
|
|
|
}
|
2014-06-03 07:22:36 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (message && 0 < message.threadsLen()) {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.gotoThread(message);
|
|
|
|
}
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.MessageListActions)) {
|
2016-08-17 06:01:20 +08:00
|
|
|
// move
|
2020-10-09 21:00:26 +08:00
|
|
|
shortcuts.add('insert', '', KeyState.MessageList, () => {
|
2020-10-13 01:46:41 +08:00
|
|
|
if (this.newMoveToFolder) {
|
2017-02-09 01:48:53 +08:00
|
|
|
this.moveNewCommand();
|
2019-07-05 03:19:24 +08:00
|
|
|
} else {
|
2017-02-09 01:48:53 +08:00
|
|
|
this.moveDropdownTrigger(true);
|
|
|
|
}
|
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
return false;
|
2016-06-30 08:02:45 +08:00
|
|
|
});
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.MessageListActions)) {
|
2016-08-17 06:01:20 +08:00
|
|
|
// read
|
2020-09-26 06:02:29 +08:00
|
|
|
shortcuts.add('q', '', [KeyState.MessageList, KeyState.MessageView], () => {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.seenMessagesFast(true);
|
|
|
|
return false;
|
|
|
|
});
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
// unread
|
2020-09-26 06:02:29 +08:00
|
|
|
shortcuts.add('u', '', [KeyState.MessageList, KeyState.MessageView], () => {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.seenMessagesFast(false);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.Composer)) {
|
2020-10-09 16:31:44 +08:00
|
|
|
shortcuts.add('f,mailforward', 'shift', [KeyState.MessageList, KeyState.MessageView], () => {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.multyForwardCommand();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (Settings.capa(Capa.Search)) {
|
2016-08-17 06:01:20 +08:00
|
|
|
// search input focus
|
2020-09-26 06:02:29 +08:00
|
|
|
shortcuts.add('/', '', [KeyState.MessageList, KeyState.MessageView], () => {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.inputMessageListSearchFocus(true);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
// cancel search
|
2020-09-26 06:02:29 +08:00
|
|
|
shortcuts.add('escape', '', KeyState.MessageList, () => {
|
2020-07-28 23:20:14 +08:00
|
|
|
if (this.messageListSearchDesc()) {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.cancelSearch();
|
|
|
|
return false;
|
2020-07-28 23:20:14 +08:00
|
|
|
} else if (this.messageListEndThreadUid()) {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.cancelThreadUid();
|
|
|
|
return false;
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
return true;
|
|
|
|
});
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
// change focused state
|
2020-09-26 06:02:29 +08:00
|
|
|
shortcuts.add('tab', 'shift', KeyState.MessageList, () => {
|
|
|
|
AppStore.focusedState(Focused.FolderList);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
shortcuts.add('arrowleft', '', KeyState.MessageList, () => {
|
|
|
|
AppStore.focusedState(Focused.FolderList);
|
|
|
|
return false;
|
|
|
|
});
|
2020-09-26 16:20:24 +08:00
|
|
|
shortcuts.add('tab,arrowright', '', KeyState.MessageList, () => {
|
2020-09-26 06:02:29 +08:00
|
|
|
this.message() && AppStore.focusedState(Focused.MessageView);
|
2016-08-17 06:01:20 +08:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2020-09-26 06:02:29 +08:00
|
|
|
shortcuts.add('arrowleft', 'meta', KeyState.MessageView, ()=>false);
|
|
|
|
shortcuts.add('arrowright', 'meta', KeyState.MessageView, ()=>false);
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
prefetchNextTick() {
|
2020-10-02 18:40:33 +08:00
|
|
|
if (ifvisible && !this.bPrefetch && !ifvisible.now() && this.viewModelVisible) {
|
2020-07-22 16:43:19 +08:00
|
|
|
const message = this.messageList().find(
|
2020-10-23 21:15:54 +08:00
|
|
|
item => item && !hasRequestedMessage(item.folder, item.uid)
|
2019-07-05 03:19:24 +08:00
|
|
|
);
|
|
|
|
if (message) {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.bPrefetch = true;
|
|
|
|
|
2020-10-23 21:15:54 +08:00
|
|
|
addRequestedMessage(message.folder, message.uid);
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
Remote.message(
|
|
|
|
(result, data) => {
|
|
|
|
const next = !!(StorageResultType.Success === result && data && data.Result);
|
2020-07-23 02:29:48 +08:00
|
|
|
setTimeout(() => {
|
2019-07-05 03:19:24 +08:00
|
|
|
this.bPrefetch = false;
|
2020-09-03 18:51:15 +08:00
|
|
|
next && this.prefetchNextTick();
|
2020-08-14 04:58:41 +08:00
|
|
|
}, 1000);
|
2019-07-05 03:19:24 +08:00
|
|
|
},
|
2020-10-23 21:15:54 +08:00
|
|
|
message.folder,
|
2019-07-05 03:19:24 +08:00
|
|
|
message.uid
|
|
|
|
);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
advancedSearchClick() {
|
2020-09-03 18:51:15 +08:00
|
|
|
Settings.capa(Capa.SearchAdv)
|
|
|
|
&& showScreenPopup(require('View/Popup/AdvancedSearch'), [this.mainMessageListSearch()]);
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
quotaTooltip() {
|
|
|
|
return i18n('MESSAGE_LIST/QUOTA_SIZE', {
|
2020-10-03 20:02:33 +08:00
|
|
|
'SIZE': File.friendlySize(this.userUsageSize()),
|
2016-08-17 06:01:20 +08:00
|
|
|
'PROC': this.userUsageProc(),
|
2020-10-03 20:02:33 +08:00
|
|
|
'LIMIT': File.friendlySize(this.userQuota())
|
2014-08-21 23:08:34 +08:00
|
|
|
});
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2013-12-09 06:14:55 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
initUploaderForAppend() {
|
2020-09-04 18:05:17 +08:00
|
|
|
if (!Settings.app('allowAppendMessage') || !this.dragOverArea()) {
|
2016-08-17 06:01:20 +08:00
|
|
|
return false;
|
2014-08-21 23:08:34 +08:00
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
const oJua = new Jua({
|
|
|
|
action: append(),
|
|
|
|
name: 'AppendFile',
|
|
|
|
queueSize: 1,
|
|
|
|
multipleSizeLimit: 1,
|
|
|
|
hidden: {
|
|
|
|
Folder: () => FolderStore.currentFolderFullNameRaw()
|
|
|
|
},
|
|
|
|
dragAndDropElement: this.dragOverArea(),
|
|
|
|
dragAndDropBodyElement: this.dragOverBodyArea()
|
|
|
|
});
|
2016-08-17 06:01:20 +08:00
|
|
|
|
2020-09-03 18:51:15 +08:00
|
|
|
this.dragOver.subscribe(value => value && this.selector.scrollToTop());
|
2015-02-22 06:00:51 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
oJua
|
2020-09-03 18:51:15 +08:00
|
|
|
.on('onDragEnter', () => this.dragOverEnter(true))
|
|
|
|
.on('onDragLeave', () => this.dragOverEnter(false))
|
|
|
|
.on('onBodyDragEnter', () => this.dragOver(true))
|
|
|
|
.on('onBodyDragLeave', () => this.dragOver(false))
|
2016-08-17 06:01:20 +08:00
|
|
|
.on('onSelect', (sUid, oData) => {
|
2019-07-05 03:19:24 +08:00
|
|
|
if (sUid && oData && 'message/rfc822' === oData.Type) {
|
2016-08-17 06:01:20 +08:00
|
|
|
MessageStore.messageListLoading(true);
|
|
|
|
return true;
|
|
|
|
}
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
return false;
|
|
|
|
})
|
2020-09-15 15:29:25 +08:00
|
|
|
.on('onComplete', () => rl.app.reloadMessageList(true, true));
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
return !!oJua;
|
|
|
|
}
|
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
export { MessageListMailBoxUserView, MessageListMailBoxUserView as default };
|