From b95541892f993381990b043071a6b16ecd4998cf Mon Sep 17 00:00:00 2001 From: djmaze <> Date: Wed, 15 Dec 2021 19:02:36 +0100 Subject: [PATCH] Better observable naming in MessageUserStore --- dev/Stores/User/Message.js | 49 ++++++++----------- dev/View/User/MailBox/MessageList.js | 6 +-- dev/View/User/MailBox/MessageView.js | 2 +- .../templates/Views/User/MailMessageList.html | 10 ++-- 4 files changed, 29 insertions(+), 38 deletions(-) diff --git a/dev/Stores/User/Message.js b/dev/Stores/User/Message.js index 2a0d31540..b42093e2d 100644 --- a/dev/Stores/User/Message.js +++ b/dev/Stores/User/Message.js @@ -88,9 +88,10 @@ export const MessageUserStore = new class { listEndPage: 1, listLoading: false, - listLoadingAnimation: false, - listIsNotCompleted: false, - listCompleteLoading: false, + // Happens when message(s) removed from list + listIsIncomplete: false, + // when this.listLoading || this.listIsIncomplete + listIsLoading: false, selectorMessageSelected: null, selectorMessageFocused: null, @@ -112,6 +113,13 @@ export const MessageUserStore = new class { // Computed Observables addComputablesTo(this, { +/* + listIsLoading: () => { + const value = this.listLoading() | this.listIsIncomplete(); + $htmlCL.toggle('list-loading', value); + return value; + }, +*/ listEndHash: () => this.listEndFolder() + '|' + @@ -168,30 +176,14 @@ export const MessageUserStore = new class { // Subscribers - let timer = 0, fn = this.listLoadingAnimation; - addSubscribablesTo(this, { - listCompleteLoading: value => { - if (value) { - fn(value); - } else if (fn()) { - clearTimeout(timer); - timer = setTimeout(() => { - fn(value); - timer = 0; - }, 700); - } else { - fn(value); - } - }, - - listLoadingAnimation: value => $htmlCL.toggle('list-loading', value), + listIsLoading: value => $htmlCL.toggle('list-loading', value), listLoading: value => - this.listCompleteLoading(value || this.listIsNotCompleted()), + this.listIsLoading(value || this.listIsIncomplete()), - listIsNotCompleted: value => - this.listCompleteLoading(value || this.listLoading()), + listIsIncomplete: value => + this.listIsLoading(value || this.listLoading()), message: message => { clearTimeout(MessageSeenTimer); @@ -323,7 +315,7 @@ export const MessageUserStore = new class { if (copy) { messages.forEach(item => item.checked(false)); } else { - this.listIsNotCompleted(true); + this.listIsIncomplete(true); messages.forEach(item => { if (currentMessage && currentMessage.hash === item.hash) { @@ -639,8 +631,7 @@ export const MessageUserStore = new class { if (collection) { let unreadCountChange = false; - const iCount = collection.MessageResultCount, - iOffset = collection.Offset, + const folder = getFolderFromCacheList(collection.Folder); if (folder && !cached) { @@ -664,9 +655,9 @@ export const MessageUserStore = new class { this.initUidNextAndNewMessages(folder.fullName, collection.UidNext, collection.NewMessages); } - this.listCount(iCount); + this.listCount(collection.MessageResultCount); this.listSearch(pString(collection.Search)); - this.listPage(Math.ceil(iOffset / SettingsUserStore.messagesPerPage() + 1)); + this.listPage(Math.ceil(collection.Offset / SettingsUserStore.messagesPerPage() + 1)); this.listThreadUid(data.Result.ThreadUid); this.listEndFolder(collection.Folder); @@ -677,7 +668,7 @@ export const MessageUserStore = new class { this.listDisableAutoSelect(true); this.list(collection); - this.listIsNotCompleted(false); + this.listIsIncomplete(false); clearNewMessageCache(); diff --git a/dev/View/User/MailBox/MessageList.js b/dev/View/User/MailBox/MessageList.js index eb800efdb..747234992 100644 --- a/dev/View/User/MailBox/MessageList.js +++ b/dev/View/User/MailBox/MessageList.js @@ -82,7 +82,7 @@ export class MailMessageList extends AbstractViewRight { this.messageListEndThreadUid = MessageUserStore.listEndThreadUid; - this.messageListCompleteLoadingThrottle = MessageUserStore.listCompleteLoading; + this.messageListIsLoading = MessageUserStore.listIsLoading; initOnStartOrLangChange(() => this.emptySubjectValue = i18n('MESSAGE_LIST/EMPTY_SUBJECT_TEXT')); @@ -263,7 +263,7 @@ export class MailMessageList extends AbstractViewRight { } reloadCommand() { - if (!MessageUserStore.listLoadingAnimation()) { + if (!MessageUserStore.listIsLoading()) { rl.app.reloadMessageList(false, true); } } @@ -602,7 +602,7 @@ export class MailMessageList extends AbstractViewRight { listEmptyMessage() { if (!this.dragOver() && !MessageUserStore.list().length - && !MessageUserStore.listCompleteLoading() + && !MessageUserStore.listIsLoading() && !MessageUserStore.listError()) { return i18n('MESSAGE_LIST/EMPTY_' + (MessageUserStore.listSearch() ? 'SEARCH_' : '') + 'LIST'); } diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index 20b09e2ac..28a6e3edb 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -177,7 +177,7 @@ export class MailMessageView extends AbstractViewRight { }, messageListOrViewLoading: - () => MessageUserStore.listCompleteLoading() | MessageUserStore.messageLoading() + () => MessageUserStore.listIsLoading() | MessageUserStore.messageLoading() }); this.addSubscribables({ diff --git a/snappymail/v/0.0.0/app/templates/Views/User/MailMessageList.html b/snappymail/v/0.0.0/app/templates/Views/User/MailMessageList.html index 33c652752..98700ef7e 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/MailMessageList.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/MailMessageList.html @@ -167,18 +167,18 @@ ⬅ -
-