From 1cd7abdc839f4ef514ee864ffc65a63106eb1a6c Mon Sep 17 00:00:00 2001 From: Hamza Date: Mon, 1 Dec 2025 16:07:02 +0100 Subject: [PATCH 1/3] fix: favority recativity Signed-off-by: Hamza --- src/store/mainStore/actions.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/store/mainStore/actions.js b/src/store/mainStore/actions.js index bfdbed933d..6ffd2e38f3 100644 --- a/src/store/mainStore/actions.js +++ b/src/store/mainStore/actions.js @@ -2062,6 +2062,15 @@ export default function mainStoreActions() { Vue.set(mailbox, 'unread', Math.max(unread - 1, 0)) } } + if (flag === 'flagged') { + envelope.flags[flag] = value + this.removeEnvelopeMutation({ id: envelope.databaseId }) + this.addEnvelopesMutation({ + query: value ? 'is:starred' : 'not:starred', + envelopes: [envelope], + }) + return + } Vue.set(envelope.flags, flag, value) }, addTagMutation({ tag }) { From 4021313455c1de78e8c3ed7bb8970de65147e6fd Mon Sep 17 00:00:00 2001 From: Hamza Date: Tue, 2 Dec 2025 19:03:09 +0100 Subject: [PATCH 2/3] fixup! fix: favority recativity Signed-off-by: Hamza --- src/store/mainStore/actions.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/store/mainStore/actions.js b/src/store/mainStore/actions.js index 6ffd2e38f3..8ce74148c6 100644 --- a/src/store/mainStore/actions.js +++ b/src/store/mainStore/actions.js @@ -116,6 +116,7 @@ import { import useOutboxStore from '../outboxStore.js' const sliceToPage = slice(0, PAGE_SIZE) +const addUniqueId = (list, id) => uniq([...(list || []), id]) const findIndividualMailboxes = curry((getMailboxes, specialRole) => pipe( filter(complement(prop('isUnified'))), @@ -2063,13 +2064,24 @@ export default function mainStoreActions() { } } if (flag === 'flagged') { - envelope.flags[flag] = value - this.removeEnvelopeMutation({ id: envelope.databaseId }) - this.addEnvelopesMutation({ - query: value ? 'is:starred' : 'not:starred', - envelopes: [envelope], + const starredLists = Object.keys(mailbox.envelopeLists).filter((key) => key.includes('is:starred')) + const notStarredLists = Object.keys(mailbox.envelopeLists).filter((key) => key.includes('not:starred')) + + starredLists.forEach((key) => { + if (value) { + Vue.set(mailbox.envelopeLists, key, addUniqueId(mailbox.envelopeLists[key], envelope.databaseId)) + } else { + Vue.set(mailbox.envelopeLists, key, (mailbox.envelopeLists[key] || []).filter((id) => id !== envelope.databaseId)) + } }) - return + notStarredLists.forEach((key) => { + if (value) { + Vue.set(mailbox.envelopeLists, key, (mailbox.envelopeLists[key] || []).filter((id) => id !== envelope.databaseId)) + } else { + Vue.set(mailbox.envelopeLists, key, addUniqueId(mailbox.envelopeLists[key], envelope.databaseId)) + } + }) + this.mailboxes[envelope.mailboxId] = mailbox } Vue.set(envelope.flags, flag, value) }, From 7e6844c96f94b19c4f3dbfc6ed7dfef8319d30bb Mon Sep 17 00:00:00 2001 From: Hamza Date: Tue, 2 Dec 2025 19:42:24 +0100 Subject: [PATCH 3/3] fixup! fix: favority recativity Signed-off-by: Hamza --- src/store/mainStore/actions.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/store/mainStore/actions.js b/src/store/mainStore/actions.js index 8ce74148c6..25ed677bc5 100644 --- a/src/store/mainStore/actions.js +++ b/src/store/mainStore/actions.js @@ -116,7 +116,6 @@ import { import useOutboxStore from '../outboxStore.js' const sliceToPage = slice(0, PAGE_SIZE) -const addUniqueId = (list, id) => uniq([...(list || []), id]) const findIndividualMailboxes = curry((getMailboxes, specialRole) => pipe( filter(complement(prop('isUnified'))), @@ -2054,6 +2053,23 @@ export default function mainStoreActions() { flag, value, }) { + const addIdToEnvelopeList = (list, id) => { + const dateOf = (msgId) => this.getEnvelope(msgId)?.dateInt ?? 0 + const sortOrder = this.getPreference('sort-order') + const newDate = dateOf(id) + let idx = 0 + if (sortOrder === 'newest') { + while (idx < list.length && dateOf(list[idx]) >= newDate) { + idx++ + } + } else { + while (idx < list.length && dateOf(list[idx]) <= newDate) { + idx++ + } + } + list.splice(idx, 0, id) + return list + } const mailbox = this.mailboxes[envelope.mailboxId] if (mailbox && flag === 'seen') { const unread = mailbox.unread ?? 0 @@ -2063,13 +2079,14 @@ export default function mainStoreActions() { Vue.set(mailbox, 'unread', Math.max(unread - 1, 0)) } } + if (flag === 'flagged') { const starredLists = Object.keys(mailbox.envelopeLists).filter((key) => key.includes('is:starred')) const notStarredLists = Object.keys(mailbox.envelopeLists).filter((key) => key.includes('not:starred')) starredLists.forEach((key) => { if (value) { - Vue.set(mailbox.envelopeLists, key, addUniqueId(mailbox.envelopeLists[key], envelope.databaseId)) + Vue.set(mailbox.envelopeLists, key, addIdToEnvelopeList(mailbox.envelopeLists[key], envelope.databaseId)) } else { Vue.set(mailbox.envelopeLists, key, (mailbox.envelopeLists[key] || []).filter((id) => id !== envelope.databaseId)) } @@ -2078,7 +2095,7 @@ export default function mainStoreActions() { if (value) { Vue.set(mailbox.envelopeLists, key, (mailbox.envelopeLists[key] || []).filter((id) => id !== envelope.databaseId)) } else { - Vue.set(mailbox.envelopeLists, key, addUniqueId(mailbox.envelopeLists[key], envelope.databaseId)) + Vue.set(mailbox.envelopeLists, key, addIdToEnvelopeList(mailbox.envelopeLists[key], envelope.databaseId)) } }) this.mailboxes[envelope.mailboxId] = mailbox