mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-01 04:22:15 +08:00
Simplify MessageUserStore
This commit is contained in:
parent
5e0f637b12
commit
227db0e0c3
10 changed files with 187 additions and 221 deletions
|
@ -146,10 +146,11 @@ class AppUser extends AbstractApp {
|
|||
}
|
||||
|
||||
reloadFlagsCurrentMessageListAndMessageFromCache() {
|
||||
MessageUserStore.messageList.forEach(message =>
|
||||
MessageUserStore.list.forEach(message =>
|
||||
MessageFlagsCache.initMessage(message)
|
||||
);
|
||||
MessageFlagsCache.initMessage(MessageUserStore.message());
|
||||
MessageUserStore.messageViewTrigger(!MessageUserStore.messageViewTrigger());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,44 +158,44 @@ class AppUser extends AbstractApp {
|
|||
* @param {boolean=} bDropCurrenFolderCache = false
|
||||
*/
|
||||
reloadMessageList(bDropPagePosition = false, bDropCurrenFolderCache = false) {
|
||||
let iOffset = (MessageUserStore.messageListPage() - 1) * SettingsUserStore.messagesPerPage();
|
||||
let iOffset = (MessageUserStore.listPage() - 1) * SettingsUserStore.messagesPerPage();
|
||||
|
||||
if (bDropCurrenFolderCache) {
|
||||
setFolderHash(FolderUserStore.currentFolderFullNameRaw(), '');
|
||||
}
|
||||
|
||||
if (bDropPagePosition) {
|
||||
MessageUserStore.messageListPage(1);
|
||||
MessageUserStore.messageListPageBeforeThread(1);
|
||||
MessageUserStore.listPage(1);
|
||||
MessageUserStore.listPageBeforeThread(1);
|
||||
iOffset = 0;
|
||||
|
||||
rl.route.setHash(
|
||||
mailBox(
|
||||
FolderUserStore.currentFolderFullNameHash(),
|
||||
MessageUserStore.messageListPage(),
|
||||
MessageUserStore.messageListSearch(),
|
||||
MessageUserStore.messageListThreadUid()
|
||||
MessageUserStore.listPage(),
|
||||
MessageUserStore.listSearch(),
|
||||
MessageUserStore.listThreadUid()
|
||||
),
|
||||
true,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
MessageUserStore.messageListLoading(true);
|
||||
MessageUserStore.listLoading(true);
|
||||
Remote.messageList(
|
||||
(sResult, oData, bCached) => {
|
||||
if (StorageResultType.Success === sResult && oData && oData.Result) {
|
||||
MessageUserStore.messageListError('');
|
||||
MessageUserStore.messageListLoading(false);
|
||||
MessageUserStore.listError('');
|
||||
MessageUserStore.listLoading(false);
|
||||
|
||||
MessageUserStore.setMessageList(oData, bCached);
|
||||
} else if (StorageResultType.Unload === sResult) {
|
||||
MessageUserStore.messageListError('');
|
||||
MessageUserStore.messageListLoading(false);
|
||||
MessageUserStore.listError('');
|
||||
MessageUserStore.listLoading(false);
|
||||
} else if (StorageResultType.Abort !== sResult) {
|
||||
MessageUserStore.messageList([]);
|
||||
MessageUserStore.messageListLoading(false);
|
||||
MessageUserStore.messageListError(
|
||||
MessageUserStore.list([]);
|
||||
MessageUserStore.listLoading(false);
|
||||
MessageUserStore.listError(
|
||||
getNotification((oData && oData.ErrorCode) || Notification.CantGetMessageList)
|
||||
);
|
||||
}
|
||||
|
@ -202,8 +203,8 @@ class AppUser extends AbstractApp {
|
|||
FolderUserStore.currentFolderFullNameRaw(),
|
||||
iOffset,
|
||||
SettingsUserStore.messagesPerPage(),
|
||||
MessageUserStore.messageListSearch(),
|
||||
MessageUserStore.messageListThreadUid()
|
||||
MessageUserStore.listSearch(),
|
||||
MessageUserStore.listThreadUid()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -294,7 +295,7 @@ class AppUser extends AbstractApp {
|
|||
}
|
||||
}
|
||||
|
||||
this.reloadMessageList(!MessageUserStore.messageList.length);
|
||||
this.reloadMessageList(!MessageUserStore.list.length);
|
||||
this.quotaDebounce();
|
||||
}
|
||||
}
|
||||
|
@ -685,8 +686,8 @@ class AppUser extends AbstractApp {
|
|||
}
|
||||
} else if (unreadCountChange
|
||||
&& folder.fullNameRaw === FolderUserStore.currentFolderFullNameRaw()
|
||||
&& MessageUserStore.messageList.length) {
|
||||
this.folderInformation(folder.fullNameRaw, MessageUserStore.messageList());
|
||||
&& MessageUserStore.list.length) {
|
||||
this.folderInformation(folder.fullNameRaw, MessageUserStore.list());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -711,7 +712,7 @@ class AppUser extends AbstractApp {
|
|||
rootUids = [];
|
||||
|
||||
if (undefined === messages || !messages) {
|
||||
messages = MessageUserStore.messageListChecked();
|
||||
messages = MessageUserStore.listChecked();
|
||||
}
|
||||
|
||||
rootUids = messages.map(oMessage => oMessage && oMessage.uid ? oMessage.uid : null)
|
||||
|
@ -764,7 +765,6 @@ class AppUser extends AbstractApp {
|
|||
}
|
||||
|
||||
this.reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||
MessageUserStore.messageViewTrigger(!MessageUserStore.messageViewTrigger());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,9 +75,9 @@ export class MailBoxUserScreen extends AbstractScreen {
|
|||
|
||||
FolderUserStore.currentFolder(folder);
|
||||
|
||||
MessageUserStore.messageListPage(page);
|
||||
MessageUserStore.messageListSearch(search);
|
||||
MessageUserStore.messageListThreadUid(threadUid);
|
||||
MessageUserStore.listPage(page);
|
||||
MessageUserStore.listSearch(search);
|
||||
MessageUserStore.listThreadUid(threadUid);
|
||||
|
||||
rl.app.reloadMessageList();
|
||||
}
|
||||
|
|
|
@ -147,14 +147,14 @@ export class GeneralUserSettings {
|
|||
).debounce(3000));
|
||||
|
||||
this.useThreads.subscribe((value) => {
|
||||
MessageUserStore.messageList([]);
|
||||
MessageUserStore.list([]);
|
||||
Remote.saveSettings(null, {
|
||||
'UseThreads': value ? 1 : 0
|
||||
});
|
||||
});
|
||||
|
||||
this.layout.subscribe((value) => {
|
||||
MessageUserStore.messageList([]);
|
||||
MessageUserStore.list([]);
|
||||
Remote.saveSettings(f2, {
|
||||
'Layout': value
|
||||
});
|
||||
|
|
|
@ -70,36 +70,34 @@ export const MessageUserStore = new class {
|
|||
constructor() {
|
||||
this.staticMessage = new MessageModel();
|
||||
|
||||
this.messageList = ko.observableArray().extend({ debounce: 0 });
|
||||
this.list = ko.observableArray().extend({ debounce: 0 });
|
||||
|
||||
ko.addObservablesTo(this, {
|
||||
messageListCount: 0,
|
||||
messageListSearch: '',
|
||||
messageListThreadUid: '',
|
||||
messageListPage: 1,
|
||||
messageListPageBeforeThread: 1,
|
||||
messageListError: '',
|
||||
listCount: 0,
|
||||
listSearch: '',
|
||||
listThreadUid: '',
|
||||
listPage: 1,
|
||||
listPageBeforeThread: 1,
|
||||
listError: '',
|
||||
|
||||
messageListEndFolder: '',
|
||||
messageListEndSearch: '',
|
||||
messageListEndThreadUid: '',
|
||||
messageListEndPage: 1,
|
||||
listEndFolder: '',
|
||||
listEndSearch: '',
|
||||
listEndThreadUid: '',
|
||||
listEndPage: 1,
|
||||
|
||||
messageListLoading: false,
|
||||
messageListIsNotCompleted: false,
|
||||
listLoading: false,
|
||||
listLoadingAnimation: false,
|
||||
listIsNotCompleted: false,
|
||||
listCompleteLoading: false,
|
||||
|
||||
selectorMessageSelected: null,
|
||||
selectorMessageFocused: null,
|
||||
|
||||
// message viewer
|
||||
message: null,
|
||||
|
||||
messageViewTrigger: false,
|
||||
|
||||
messageError: '',
|
||||
|
||||
messageCurrentLoading: false,
|
||||
|
||||
messageLoading: false,
|
||||
messageFullScreenMode: false,
|
||||
|
||||
// Cache mail bodies
|
||||
|
@ -107,102 +105,72 @@ export const MessageUserStore = new class {
|
|||
messageActiveDom: null
|
||||
});
|
||||
|
||||
this.messageListCompleteLoadingThrottle = ko.observable(false).extend({ debounce: 200 });
|
||||
this.messageListCompleteLoadingThrottleForAnimation = ko.observable(false);
|
||||
this.listDisableAutoSelect = ko.observable(false).extend({ falseTimeout: 500 });
|
||||
|
||||
this.messageListDisableAutoSelect = ko.observable(false).extend({ falseTimeout: 500 });
|
||||
// Computed Observables
|
||||
|
||||
this.messageLoadingThrottle = ko.observable(false).extend({ debounce: 50 });
|
||||
|
||||
this.messageLoading = ko.computed(() => this.messageCurrentLoading());
|
||||
|
||||
this.messageListEndHash = ko.computed(
|
||||
this.listEndHash = ko.computed(
|
||||
() =>
|
||||
this.messageListEndFolder() +
|
||||
this.listEndFolder() +
|
||||
'|' +
|
||||
this.messageListEndSearch() +
|
||||
this.listEndSearch() +
|
||||
'|' +
|
||||
this.messageListEndThreadUid() +
|
||||
this.listEndThreadUid() +
|
||||
'|' +
|
||||
this.messageListEndPage()
|
||||
this.listEndPage()
|
||||
);
|
||||
|
||||
this.messageListPageCount = ko.computed(() => {
|
||||
const page = Math.ceil(this.messageListCount() / SettingsUserStore.messagesPerPage());
|
||||
return 0 >= page ? 1 : page;
|
||||
});
|
||||
this.listPageCount = ko.computed(() =>
|
||||
Math.max(1, Math.ceil(this.listCount() / SettingsUserStore.messagesPerPage()))
|
||||
);
|
||||
|
||||
this.mainMessageListSearch = ko.computed({
|
||||
read: this.messageListSearch,
|
||||
write: (value) => {
|
||||
read: this.listSearch,
|
||||
write: value =>
|
||||
rl.route.setHash(
|
||||
mailBox(FolderUserStore.currentFolderFullNameHash(), 1, value.toString().trim(), this.messageListThreadUid())
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
this.messageListCompleteLoading = ko.computed(() => {
|
||||
const one = this.messageListLoading(),
|
||||
two = this.messageListIsNotCompleted();
|
||||
return one || two;
|
||||
mailBox(FolderUserStore.currentFolderFullNameHash(), 1, value.toString().trim(), this.listThreadUid())
|
||||
)
|
||||
});
|
||||
|
||||
this.isMessageSelected = ko.computed(() => null !== this.message());
|
||||
|
||||
this.messageListChecked = ko
|
||||
.computed(() => this.messageList.filter(isChecked))
|
||||
this.listChecked = ko
|
||||
.computed(() => this.list.filter(isChecked))
|
||||
.extend({ rateLimit: 0 });
|
||||
|
||||
this.hasCheckedMessages = ko
|
||||
.computed(() => !!this.messageList.find(isChecked))
|
||||
.computed(() => !!this.list.find(isChecked))
|
||||
.extend({ rateLimit: 0 });
|
||||
|
||||
this.hasCheckedOrSelected = ko
|
||||
.computed(() => !!(this.selectorMessageSelected()
|
||||
|| this.selectorMessageFocused()
|
||||
|| this.messageList.find(item => item.checked())))
|
||||
|| this.list.find(item => item.checked())))
|
||||
.extend({ rateLimit: 50 });
|
||||
|
||||
this.messageListCheckedOrSelected = ko.computed(() => {
|
||||
const checked = this.messageListChecked(),
|
||||
this.listCheckedOrSelected = ko.computed(() => {
|
||||
const
|
||||
selectedMessage = this.selectorMessageSelected(),
|
||||
focusedMessage = this.selectorMessageFocused();
|
||||
|
||||
if (checked.length) {
|
||||
return selectedMessage
|
||||
? checked.concat([selectedMessage]).unique()
|
||||
: checked;
|
||||
}
|
||||
|
||||
return selectedMessage ? [selectedMessage] : (focusedMessage ? [focusedMessage] : []);
|
||||
focusedMessage = this.selectorMessageFocused(),
|
||||
checked = this.list.filter(item => isChecked(item) || item === selectedMessage);
|
||||
return checked.length ? checked : (focusedMessage ? [focusedMessage] : []);
|
||||
});
|
||||
|
||||
this.messageListCheckedOrSelectedUidsWithSubMails = ko.computed(() => {
|
||||
this.listCheckedOrSelectedUidsWithSubMails = ko.computed(() => {
|
||||
let result = [];
|
||||
this.messageListCheckedOrSelected().forEach(message => {
|
||||
if (message) {
|
||||
result.push(message.uid);
|
||||
if (1 < message.threadsLen()) {
|
||||
result = result.concat(message.threads()).unique();
|
||||
}
|
||||
this.listCheckedOrSelected().forEach(message => {
|
||||
result.push(message.uid);
|
||||
if (1 < message.threadsLen()) {
|
||||
result = result.concat(message.threads()).unique();
|
||||
}
|
||||
});
|
||||
return result;
|
||||
});
|
||||
|
||||
this.subscribers();
|
||||
|
||||
this.onMessageResponse = this.onMessageResponse.bind(this);
|
||||
|
||||
this.purgeMessageBodyCacheThrottle = this.purgeMessageBodyCache.throttle(30000);
|
||||
}
|
||||
|
||||
subscribers() {
|
||||
let timer = 0, fn = this.messageListCompleteLoadingThrottleForAnimation;
|
||||
this.messageListCompleteLoading.subscribe((value) => {
|
||||
value = !!value;
|
||||
this.messageListCompleteLoadingThrottle(value);
|
||||
// Subscribers
|
||||
|
||||
let timer = 0, fn = this.listLoadingAnimation;
|
||||
this.listCompleteLoading.subscribe(value => {
|
||||
if (value) {
|
||||
fn(value);
|
||||
} else if (fn()) {
|
||||
|
@ -216,8 +184,15 @@ export const MessageUserStore = new class {
|
|||
}
|
||||
});
|
||||
|
||||
this.messageList.subscribe(
|
||||
(list=> {
|
||||
this.listLoading.subscribe(value =>
|
||||
this.listCompleteLoading(value || this.listIsNotCompleted())
|
||||
);
|
||||
this.listIsNotCompleted.subscribe(value =>
|
||||
this.listCompleteLoading(value || this.listLoading())
|
||||
);
|
||||
|
||||
this.list.subscribe(
|
||||
(list => {
|
||||
list.forEach(item =>
|
||||
item && item.newForAnimation() && item.newForAnimation(false)
|
||||
)
|
||||
|
@ -237,14 +212,16 @@ export const MessageUserStore = new class {
|
|||
}
|
||||
});
|
||||
|
||||
this.messageLoading.subscribe(value => this.messageLoadingThrottle(value));
|
||||
|
||||
this.messageListEndFolder.subscribe(folder => {
|
||||
this.listEndFolder.subscribe(folder => {
|
||||
const message = this.message();
|
||||
if (message && folder && folder !== message.folder) {
|
||||
this.message(null);
|
||||
}
|
||||
});
|
||||
|
||||
this.onMessageResponse = this.onMessageResponse.bind(this);
|
||||
|
||||
this.purgeMessageBodyCacheThrottle = this.purgeMessageBodyCache.throttle(30000);
|
||||
}
|
||||
|
||||
purgeMessageBodyCache() {
|
||||
|
@ -303,7 +280,7 @@ export const MessageUserStore = new class {
|
|||
uidForRemove = uidForRemove.map(mValue => pInt(mValue));
|
||||
|
||||
let unseenCount = 0,
|
||||
messageList = this.messageList,
|
||||
messageList = this.list,
|
||||
currentMessage = this.message();
|
||||
|
||||
const trashFolder = FolderUserStore.trashFolder(),
|
||||
|
@ -349,11 +326,9 @@ export const MessageUserStore = new class {
|
|||
|
||||
if (messages.length) {
|
||||
if (copy) {
|
||||
messages.forEach(item => {
|
||||
item.checked(false);
|
||||
});
|
||||
messages.forEach(item => item.checked(false));
|
||||
} else {
|
||||
this.messageListIsNotCompleted(true);
|
||||
this.listIsNotCompleted(true);
|
||||
|
||||
messages.forEach(item => {
|
||||
if (currentMessage && currentMessage.hash === item.hash) {
|
||||
|
@ -364,11 +339,7 @@ export const MessageUserStore = new class {
|
|||
item.deleted(true);
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
messages.forEach(item => {
|
||||
messageList.remove(item);
|
||||
});
|
||||
}, 350);
|
||||
setTimeout(() => messages.forEach(item => messageList.remove(item)), 350);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -380,47 +351,47 @@ export const MessageUserStore = new class {
|
|||
setFolderHash(toFolderFullNameRaw, '');
|
||||
}
|
||||
|
||||
if (this.messageListThreadUid()) {
|
||||
if (this.listThreadUid()) {
|
||||
if (
|
||||
messageList.length &&
|
||||
!!messageList.find(item => !!(item && item.deleted() && item.uid === this.messageListThreadUid()))
|
||||
!!messageList.find(item => !!(item && item.deleted() && item.uid === this.listThreadUid()))
|
||||
) {
|
||||
const message = messageList.find(item => item && !item.deleted());
|
||||
if (message && this.messageListThreadUid() !== pString(message.uid)) {
|
||||
this.messageListThreadUid(pString(message.uid));
|
||||
if (message && this.listThreadUid() !== pString(message.uid)) {
|
||||
this.listThreadUid(pString(message.uid));
|
||||
|
||||
rl.route.setHash(
|
||||
mailBox(
|
||||
FolderUserStore.currentFolderFullNameHash(),
|
||||
this.messageListPage(),
|
||||
this.messageListSearch(),
|
||||
this.messageListThreadUid()
|
||||
this.listPage(),
|
||||
this.listSearch(),
|
||||
this.listThreadUid()
|
||||
),
|
||||
true,
|
||||
true
|
||||
);
|
||||
} else if (!message) {
|
||||
if (1 < this.messageListPage()) {
|
||||
this.messageListPage(this.messageListPage() - 1);
|
||||
if (1 < this.listPage()) {
|
||||
this.listPage(this.listPage() - 1);
|
||||
|
||||
rl.route.setHash(
|
||||
mailBox(
|
||||
FolderUserStore.currentFolderFullNameHash(),
|
||||
this.messageListPage(),
|
||||
this.messageListSearch(),
|
||||
this.messageListThreadUid()
|
||||
this.listPage(),
|
||||
this.listSearch(),
|
||||
this.listThreadUid()
|
||||
),
|
||||
true,
|
||||
true
|
||||
);
|
||||
} else {
|
||||
this.messageListThreadUid('');
|
||||
this.listThreadUid('');
|
||||
|
||||
rl.route.setHash(
|
||||
mailBox(
|
||||
FolderUserStore.currentFolderFullNameHash(),
|
||||
this.messageListPageBeforeThread(),
|
||||
this.messageListSearch()
|
||||
this.listPageBeforeThread(),
|
||||
this.listSearch()
|
||||
),
|
||||
true,
|
||||
true
|
||||
|
@ -612,11 +583,11 @@ export const MessageUserStore = new class {
|
|||
(message.folder !== selectedMessage.folder || message.uid !== selectedMessage.uid)
|
||||
) {
|
||||
this.selectorMessageSelected(null);
|
||||
if (1 === this.messageList.length) {
|
||||
if (1 === this.list.length) {
|
||||
this.selectorMessageFocused(null);
|
||||
}
|
||||
} else if (!selectedMessage && message) {
|
||||
selectedMessage = this.messageList.find(
|
||||
selectedMessage = this.list.find(
|
||||
subMessage =>
|
||||
subMessage &&
|
||||
subMessage.folder === message.folder &&
|
||||
|
@ -655,8 +626,10 @@ export const MessageUserStore = new class {
|
|||
}
|
||||
|
||||
populateMessageBody(oMessage) {
|
||||
if (oMessage && Remote.message(this.onMessageResponse, oMessage.folder, oMessage.uid)) {
|
||||
this.messageCurrentLoading(true);
|
||||
if (oMessage) {
|
||||
this.hideMessageBodies();
|
||||
this.messageLoading(true);
|
||||
Remote.message(this.onMessageResponse, oMessage.folder, oMessage.uid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -666,10 +639,6 @@ export const MessageUserStore = new class {
|
|||
* @param {boolean} bCached
|
||||
*/
|
||||
onMessageResponse(sResult, oData, bCached) {
|
||||
this.hideMessageBodies();
|
||||
|
||||
this.messageCurrentLoading(false);
|
||||
|
||||
if (StorageResultType.Success === sResult && oData && oData.Result) {
|
||||
this.setMessage(oData, bCached);
|
||||
} else if (StorageResultType.Unload === sResult) {
|
||||
|
@ -681,6 +650,8 @@ export const MessageUserStore = new class {
|
|||
oData && oData.ErrorCode ? getNotification(oData.ErrorCode) : getNotification(Notification.UnknownError)
|
||||
);
|
||||
}
|
||||
|
||||
this.messageLoading(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -723,20 +694,20 @@ export const MessageUserStore = new class {
|
|||
this.initUidNextAndNewMessages(folder.fullNameRaw, collection.UidNext, collection.NewMessages);
|
||||
}
|
||||
|
||||
this.messageListCount(iCount);
|
||||
this.messageListSearch(pString(collection.Search));
|
||||
this.messageListPage(Math.ceil(iOffset / SettingsUserStore.messagesPerPage() + 1));
|
||||
this.messageListThreadUid(pString(data.Result.ThreadUid));
|
||||
this.listCount(iCount);
|
||||
this.listSearch(pString(collection.Search));
|
||||
this.listPage(Math.ceil(iOffset / SettingsUserStore.messagesPerPage() + 1));
|
||||
this.listThreadUid(pString(data.Result.ThreadUid));
|
||||
|
||||
this.messageListEndFolder(collection.Folder);
|
||||
this.messageListEndSearch(this.messageListSearch());
|
||||
this.messageListEndThreadUid(this.messageListThreadUid());
|
||||
this.messageListEndPage(this.messageListPage());
|
||||
this.listEndFolder(collection.Folder);
|
||||
this.listEndSearch(this.listSearch());
|
||||
this.listEndThreadUid(this.listThreadUid());
|
||||
this.listEndPage(this.listPage());
|
||||
|
||||
this.messageListDisableAutoSelect(true);
|
||||
this.listDisableAutoSelect(true);
|
||||
|
||||
this.messageList(collection);
|
||||
this.messageListIsNotCompleted(false);
|
||||
this.list(collection);
|
||||
this.listIsNotCompleted(false);
|
||||
|
||||
clearNewMessageCache();
|
||||
|
||||
|
@ -744,9 +715,9 @@ export const MessageUserStore = new class {
|
|||
rl.app.folderInformation(folder.fullNameRaw, collection);
|
||||
}
|
||||
} else {
|
||||
this.messageListCount(0);
|
||||
this.messageList([]);
|
||||
this.messageListError(getNotification(data && data.ErrorCode ? data.ErrorCode : Notification.CantGetMessageList));
|
||||
this.listCount(0);
|
||||
this.list([]);
|
||||
this.listError(getNotification(data && data.ErrorCode ? data.ErrorCode : Notification.CantGetMessageList));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -10,10 +10,6 @@ export const TemplateUserStore = new class {
|
|||
this.templatesNames = ko.observableArray().extend({ debounce: 1000 });
|
||||
this.templatesNames.skipFirst = true;
|
||||
|
||||
this.subscribers();
|
||||
}
|
||||
|
||||
subscribers() {
|
||||
this.templates.subscribe((list) => {
|
||||
this.templatesNames(list.map(item => (item ? item.name : null)).filter(v => v));
|
||||
});
|
||||
|
|
|
@ -28,7 +28,7 @@ class LoginAdminView extends AbstractViewCenter {
|
|||
submitError: ''
|
||||
});
|
||||
|
||||
this.formError = ko.observable(false).extend({ 'falseTimeout': 500 });
|
||||
this.formError = ko.observable(false).extend({ falseTimeout: 500 });
|
||||
|
||||
this.addSubscribables({
|
||||
login: () => this.loginError(false),
|
||||
|
|
|
@ -45,7 +45,7 @@ class FolderClearPopupView extends AbstractViewPopup {
|
|||
const folderToClear = this.selectedFolder();
|
||||
if (folderToClear) {
|
||||
MessageUserStore.message(null);
|
||||
MessageUserStore.messageList([]);
|
||||
MessageUserStore.list([]);
|
||||
|
||||
this.clearingProcess(true);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ export class FolderListMailBoxUserView extends AbstractViewLeft {
|
|||
|
||||
this.composeInEdit = AppUserStore.composeInEdit;
|
||||
|
||||
this.messageList = MessageUserStore.messageList;
|
||||
this.messageList = MessageUserStore.list;
|
||||
this.folderList = FolderUserStore.folderList;
|
||||
this.folderListSystem = FolderUserStore.folderListSystem;
|
||||
this.foldersChanging = FolderUserStore.foldersChanging;
|
||||
|
@ -47,7 +47,7 @@ export class FolderListMailBoxUserView extends AbstractViewLeft {
|
|||
() =>
|
||||
FolderUserStore.currentFolder() &&
|
||||
FolderUserStore.currentFolder().isInbox() &&
|
||||
MessageUserStore.messageListSearch().trim().includes('is:flagged')
|
||||
MessageUserStore.listSearch().trim().includes('is:flagged')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ export class FolderListMailBoxUserView extends AbstractViewLeft {
|
|||
moveAction(false);
|
||||
rl.app.moveMessagesToFolder(
|
||||
FolderUserStore.currentFolderFullNameRaw(),
|
||||
MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails(),
|
||||
MessageUserStore.listCheckedOrSelectedUidsWithSubMails(),
|
||||
folder.fullNameRaw,
|
||||
event.ctrlKey
|
||||
);
|
||||
|
|
|
@ -72,8 +72,8 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
this.popupVisibility = popupVisibility;
|
||||
|
||||
this.message = MessageUserStore.message;
|
||||
this.messageList = MessageUserStore.messageList;
|
||||
this.messageListDisableAutoSelect = MessageUserStore.messageListDisableAutoSelect;
|
||||
this.messageList = MessageUserStore.list;
|
||||
this.messageListDisableAutoSelect = MessageUserStore.listDisableAutoSelect;
|
||||
|
||||
this.folderList = FolderUserStore.folderList;
|
||||
|
||||
|
@ -83,22 +83,21 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
this.selectorMessageSelected = MessageUserStore.selectorMessageSelected;
|
||||
this.selectorMessageFocused = MessageUserStore.selectorMessageFocused;
|
||||
this.isMessageSelected = MessageUserStore.isMessageSelected;
|
||||
this.messageListSearch = MessageUserStore.messageListSearch;
|
||||
this.messageListThreadUid = MessageUserStore.messageListThreadUid;
|
||||
this.messageListError = MessageUserStore.messageListError;
|
||||
this.messageListSearch = MessageUserStore.listSearch;
|
||||
this.messageListThreadUid = MessageUserStore.listThreadUid;
|
||||
this.messageListError = MessageUserStore.listError;
|
||||
this.folderMenuForMove = FolderUserStore.folderMenuForMove;
|
||||
|
||||
this.useCheckboxesInList = SettingsUserStore.useCheckboxesInList;
|
||||
|
||||
this.mainMessageListSearch = MessageUserStore.mainMessageListSearch;
|
||||
this.messageListEndFolder = MessageUserStore.messageListEndFolder;
|
||||
this.messageListEndThreadUid = MessageUserStore.messageListEndThreadUid;
|
||||
this.messageListEndFolder = MessageUserStore.listEndFolder;
|
||||
this.messageListEndThreadUid = MessageUserStore.listEndThreadUid;
|
||||
|
||||
this.messageListCheckedOrSelected = MessageUserStore.messageListCheckedOrSelected;
|
||||
this.messageListCheckedOrSelectedUidsWithSubMails = MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails;
|
||||
this.messageListCompleteLoadingThrottle = MessageUserStore.messageListCompleteLoadingThrottle;
|
||||
this.messageListCompleteLoadingThrottleForAnimation =
|
||||
MessageUserStore.messageListCompleteLoadingThrottleForAnimation;
|
||||
this.messageListCheckedOrSelected = MessageUserStore.listCheckedOrSelected;
|
||||
this.messageListCheckedOrSelectedUidsWithSubMails = MessageUserStore.listCheckedOrSelectedUidsWithSubMails;
|
||||
this.messageListCompleteLoadingThrottle = MessageUserStore.listCompleteLoading;
|
||||
this.messageListCompleteLoadingThrottleForAnimation = MessageUserStore.listLoadingAnimation;
|
||||
|
||||
initOnStartOrLangChange(() => this.emptySubjectValue = i18n('MESSAGE_LIST/EMPTY_SUBJECT_TEXT'));
|
||||
|
||||
|
@ -124,18 +123,18 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
|
||||
this.addComputables({
|
||||
messageListSearchDesc: () => {
|
||||
const value = MessageUserStore.messageListEndSearch();
|
||||
const value = MessageUserStore.listEndSearch();
|
||||
return value ? i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', { 'SEARCH': value }) : ''
|
||||
},
|
||||
|
||||
messageListPaginator: computedPaginatorHelper(MessageUserStore.messageListPage,
|
||||
MessageUserStore.messageListPageCount),
|
||||
messageListPaginator: computedPaginatorHelper(MessageUserStore.listPage,
|
||||
MessageUserStore.listPageCount),
|
||||
|
||||
checkAll: {
|
||||
read: () => 0 < MessageUserStore.messageListChecked().length,
|
||||
read: () => 0 < MessageUserStore.listChecked().length,
|
||||
write: (value) => {
|
||||
value = !!value;
|
||||
MessageUserStore.messageList.forEach(message => message.checked(value));
|
||||
MessageUserStore.list.forEach(message => message.checked(value));
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -145,8 +144,8 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
},
|
||||
|
||||
isIncompleteChecked: () => {
|
||||
const c = MessageUserStore.messageListChecked().length;
|
||||
return c && MessageUserStore.messageList.length > c;
|
||||
const c = MessageUserStore.listChecked().length;
|
||||
return c && MessageUserStore.list.length > c;
|
||||
},
|
||||
|
||||
hasMessages: () => 0 < this.messageList.length,
|
||||
|
@ -173,14 +172,14 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
isUnSpamVisible: () =>
|
||||
this.isSpamFolder() && !this.isSpamDisabled() && !this.isDraftFolder() && !this.isSentFolder(),
|
||||
|
||||
mobileCheckedStateShow: () => ThemeStore.isMobile() ? 0 < MessageUserStore.messageListChecked().length : true,
|
||||
mobileCheckedStateShow: () => ThemeStore.isMobile() ? 0 < MessageUserStore.listChecked().length : true,
|
||||
|
||||
mobileCheckedStateHide: () => ThemeStore.isMobile() ? !MessageUserStore.messageListChecked().length : true,
|
||||
mobileCheckedStateHide: () => ThemeStore.isMobile() ? !MessageUserStore.listChecked().length : true,
|
||||
|
||||
messageListFocused: () => Focused.MessageList === AppUserStore.focusedState()
|
||||
});
|
||||
|
||||
// this.messageListChecked = MessageUserStore.messageListChecked;
|
||||
// this.messageListChecked = MessageUserStore.listChecked;
|
||||
|
||||
this.hasCheckedOrSelectedLines = MessageUserStore.hasCheckedOrSelected,
|
||||
|
||||
|
@ -234,7 +233,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
}
|
||||
});
|
||||
|
||||
MessageUserStore.messageListEndHash.subscribe((() =>
|
||||
MessageUserStore.listEndHash.subscribe((() =>
|
||||
this.selector.scrollToFocused()
|
||||
).throttle(50));
|
||||
|
||||
|
@ -259,7 +258,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
}
|
||||
|
||||
reloadCommand() {
|
||||
if (!MessageUserStore.messageListCompleteLoadingThrottleForAnimation() && this.allowReload) {
|
||||
if (!MessageUserStore.listLoadingAnimation() && this.allowReload) {
|
||||
rl.app.reloadMessageList(false, true);
|
||||
}
|
||||
}
|
||||
|
@ -267,7 +266,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
multyForwardCommand() {
|
||||
showMessageComposer([
|
||||
ComposeType.ForwardAsAttachment,
|
||||
MessageUserStore.messageListCheckedOrSelected()
|
||||
MessageUserStore.listCheckedOrSelected()
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -276,7 +275,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
rl.app.deleteMessagesFromFolder(
|
||||
FolderType.Trash,
|
||||
FolderUserStore.currentFolderFullNameRaw(),
|
||||
MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails(),
|
||||
MessageUserStore.listCheckedOrSelectedUidsWithSubMails(),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
@ -286,7 +285,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
rl.app.deleteMessagesFromFolder(
|
||||
FolderType.Trash,
|
||||
FolderUserStore.currentFolderFullNameRaw(),
|
||||
MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails(),
|
||||
MessageUserStore.listCheckedOrSelectedUidsWithSubMails(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
@ -295,7 +294,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
rl.app.deleteMessagesFromFolder(
|
||||
FolderType.Archive,
|
||||
FolderUserStore.currentFolderFullNameRaw(),
|
||||
MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails(),
|
||||
MessageUserStore.listCheckedOrSelectedUidsWithSubMails(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
@ -304,7 +303,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
rl.app.deleteMessagesFromFolder(
|
||||
FolderType.Spam,
|
||||
FolderUserStore.currentFolderFullNameRaw(),
|
||||
MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails(),
|
||||
MessageUserStore.listCheckedOrSelectedUidsWithSubMails(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
@ -313,7 +312,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
rl.app.deleteMessagesFromFolder(
|
||||
FolderType.NotSpam,
|
||||
FolderUserStore.currentFolderFullNameRaw(),
|
||||
MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails(),
|
||||
MessageUserStore.listCheckedOrSelectedUidsWithSubMails(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
@ -352,7 +351,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
}
|
||||
|
||||
goToUpUpOrDownDown(up) {
|
||||
if (MessageUserStore.messageListChecked().length) {
|
||||
if (MessageUserStore.listChecked().length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -416,8 +415,8 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
rl.route.setHash(
|
||||
mailBox(
|
||||
FolderUserStore.currentFolderFullNameHash(),
|
||||
MessageUserStore.messageListPageBeforeThread(),
|
||||
MessageUserStore.messageListSearch()
|
||||
MessageUserStore.listPageBeforeThread(),
|
||||
MessageUserStore.listSearch()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -431,7 +430,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
if (MessageUserStore.hasCheckedOrSelected()) {
|
||||
rl.app.moveMessagesToFolder(
|
||||
FolderUserStore.currentFolderFullNameRaw(),
|
||||
MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails(),
|
||||
MessageUserStore.listCheckedOrSelectedUidsWithSubMails(),
|
||||
sToFolderFullNameRaw,
|
||||
bCopy
|
||||
);
|
||||
|
@ -443,7 +442,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
getDragData(event) {
|
||||
const item = ko.dataFor(doc.elementFromPoint(event.clientX, event.clientY));
|
||||
item && item.checked && item.checked(true);
|
||||
const uids = MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails();
|
||||
const uids = MessageUserStore.listCheckedOrSelectedUidsWithSubMails();
|
||||
item && !uids.includes(item.uid) && uids.push(item.uid);
|
||||
return uids.length ? {
|
||||
copy: event.ctrlKey,
|
||||
|
@ -479,7 +478,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
case MessageSetAction.SetSeen:
|
||||
folder = getFolderFromCacheList(sFolderFullNameRaw);
|
||||
if (folder) {
|
||||
MessageUserStore.messageList.forEach(message => {
|
||||
MessageUserStore.list.forEach(message => {
|
||||
if (message.isUnseen()) {
|
||||
++cnt;
|
||||
}
|
||||
|
@ -505,7 +504,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
case MessageSetAction.UnsetSeen:
|
||||
folder = getFolderFromCacheList(sFolderFullNameRaw);
|
||||
if (folder) {
|
||||
MessageUserStore.messageList.forEach(message => {
|
||||
MessageUserStore.list.forEach(message => {
|
||||
if (!message.isUnseen()) {
|
||||
++cnt;
|
||||
}
|
||||
|
@ -540,7 +539,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
this.setAction(
|
||||
FolderUserStore.currentFolderFullNameRaw(),
|
||||
MessageSetAction.SetSeen,
|
||||
MessageUserStore.messageListCheckedOrSelected()
|
||||
MessageUserStore.listCheckedOrSelected()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -556,7 +555,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
this.setAction(
|
||||
FolderUserStore.currentFolderFullNameRaw(),
|
||||
MessageSetAction.UnsetSeen,
|
||||
MessageUserStore.messageListCheckedOrSelected()
|
||||
MessageUserStore.listCheckedOrSelected()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -564,7 +563,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
this.setAction(
|
||||
FolderUserStore.currentFolderFullNameRaw(),
|
||||
MessageSetAction.SetFlag,
|
||||
MessageUserStore.messageListCheckedOrSelected()
|
||||
MessageUserStore.listCheckedOrSelected()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -572,7 +571,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
this.setAction(
|
||||
FolderUserStore.currentFolderFullNameRaw(),
|
||||
MessageSetAction.UnsetFlag,
|
||||
MessageUserStore.messageListCheckedOrSelected()
|
||||
MessageUserStore.listCheckedOrSelected()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -641,18 +640,18 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
mailBox(
|
||||
FolderUserStore.currentFolderFullNameHash(),
|
||||
page.value,
|
||||
MessageUserStore.messageListSearch(),
|
||||
MessageUserStore.messageListThreadUid()
|
||||
MessageUserStore.listSearch(),
|
||||
MessageUserStore.listThreadUid()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
gotoThread(message) {
|
||||
if (message && 0 < message.threadsLen()) {
|
||||
MessageUserStore.messageListPageBeforeThread(MessageUserStore.messageListPage());
|
||||
MessageUserStore.listPageBeforeThread(MessageUserStore.listPage());
|
||||
|
||||
rl.route.setHash(
|
||||
mailBox(FolderUserStore.currentFolderFullNameHash(), 1, MessageUserStore.messageListSearch(), message.uid)
|
||||
mailBox(FolderUserStore.currentFolderFullNameHash(), 1, MessageUserStore.listSearch(), message.uid)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -723,12 +722,12 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
|
||||
// delete
|
||||
shortcuts.add('delete', 'shift', KeyState.MessageList, () => {
|
||||
MessageUserStore.messageListCheckedOrSelected().length && this.deleteWithoutMoveCommand();
|
||||
MessageUserStore.listCheckedOrSelected().length && this.deleteWithoutMoveCommand();
|
||||
return false;
|
||||
});
|
||||
// shortcuts.add('3', 'shift', KeyState.MessageList, () => {
|
||||
shortcuts.add('delete', '', KeyState.MessageList, () => {
|
||||
MessageUserStore.messageListCheckedOrSelected().length && this.deleteCommand();
|
||||
MessageUserStore.listCheckedOrSelected().length && this.deleteCommand();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
@ -909,7 +908,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
|
|||
.on('onBodyDragLeave', () => this.dragOver(false))
|
||||
.on('onSelect', (sUid, oData) => {
|
||||
if (sUid && oData && 'message/rfc822' === oData.Type) {
|
||||
MessageUserStore.messageListLoading(true);
|
||||
MessageUserStore.listLoading(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,10 +82,10 @@ class MessageViewMailBoxUserView extends AbstractViewRight {
|
|||
this.attachmentsActions = AppUserStore.attachmentsActions;
|
||||
|
||||
this.message = MessageUserStore.message;
|
||||
// this.messageListChecked = MessageUserStore.messageListChecked;
|
||||
// this.messageListChecked = MessageUserStore.listChecked;
|
||||
this.hasCheckedMessages = MessageUserStore.hasCheckedMessages;
|
||||
this.messageListCheckedOrSelectedUidsWithSubMails = MessageUserStore.messageListCheckedOrSelectedUidsWithSubMails;
|
||||
this.messageLoadingThrottle = MessageUserStore.messageLoadingThrottle;
|
||||
this.messageListCheckedOrSelectedUidsWithSubMails = MessageUserStore.listCheckedOrSelectedUidsWithSubMails;
|
||||
this.messageLoadingThrottle = MessageUserStore.messageLoading;
|
||||
this.messagesBodiesDom = MessageUserStore.messagesBodiesDom;
|
||||
this.useThreads = SettingsUserStore.useThreads;
|
||||
this.replySameFolder = SettingsUserStore.replySameFolder;
|
||||
|
@ -158,7 +158,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight {
|
|||
)
|
||||
},
|
||||
|
||||
messageVisibility: () => !this.messageLoadingThrottle() && !!this.message(),
|
||||
messageVisibility: () => !MessageUserStore.messageLoading() && !!this.message(),
|
||||
|
||||
canBeRepliedOrForwarded: () => !this.isDraftFolder() && this.messageVisibility(),
|
||||
|
||||
|
@ -189,7 +189,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight {
|
|||
messageFocused: () => Focused.MessageView === AppUserStore.focusedState(),
|
||||
|
||||
messageListAndMessageViewLoading:
|
||||
() => MessageUserStore.messageListCompleteLoadingThrottle() || MessageUserStore.messageLoadingThrottle()
|
||||
() => MessageUserStore.listCompleteLoading() || MessageUserStore.messageLoading()
|
||||
});
|
||||
|
||||
this.addSubscribables({
|
||||
|
@ -255,7 +255,7 @@ class MessageViewMailBoxUserView extends AbstractViewRight {
|
|||
|
||||
MessageUserStore.messageViewTrigger.subscribe(() => {
|
||||
const message = this.message();
|
||||
message ? this.viewIsFlagged(message.isFlagged()) : this.viewIsFlagged(false);
|
||||
this.viewIsFlagged(message ? message.isFlagged() : false);
|
||||
});
|
||||
|
||||
this.lastReplyAction(Local.get(ClientSideKeyName.LastReplyAction) || ComposeType.Reply);
|
||||
|
|
Loading…
Reference in a new issue