From fe70ebff0852e001491c6eb4d20f54e5bf687e1a Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Wed, 19 Nov 2025 22:01:40 +0100 Subject: [PATCH] fix(search): apply correct search query when fetching envelopes Signed-off-by: Daniel Kesselberg --- src/components/MailboxThread.vue | 13 +++++-------- src/store/mainStore/actions.js | 10 +++++++++- src/tests/unit/store/actions.spec.js | 8 +++++--- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/components/MailboxThread.vue b/src/components/MailboxThread.vue index 5977eb50b0..7303e7dbf0 100644 --- a/src/components/MailboxThread.vue +++ b/src/components/MailboxThread.vue @@ -260,7 +260,7 @@ export default { return this.mainStore.getEnvelopes(this.mailbox.databaseId, this.appendToSearch(priorityImportantQuery)).length > 0 || this.mainStore.getEnvelopes(this.mailbox.databaseId, this.appendToSearch(priorityOtherQuery)).length > 0 } - return this.mainStore.getEnvelopes(this.mailbox.databaseId, this.searchQuery).length > 0 + return this.mainStore.getEnvelopes(this.mailbox.databaseId, this.query).length > 0 }, hasImportantEnvelopes() { @@ -316,10 +316,7 @@ export default { query() { if (this.$route.params.filter === 'starred') { - if (this.searchQuery) { - return this.appendToSearch('is:starred') - } - return 'is:starred' + return this.appendToSearch('is:starred') } return this.searchQuery }, @@ -329,7 +326,7 @@ export default { }, groupEnvelopes() { - const allEnvelopes = this.mainStore.getEnvelopes(this.mailbox.databaseId, this.searchQuery) + const allEnvelopes = this.mainStore.getEnvelopes(this.mailbox.databaseId, this.query) return this.getGroupedEnvelopes(allEnvelopes, this.mainStore.syncTimestamp, this.sortOrder) }, @@ -384,11 +381,11 @@ export default { }, async fetchEnvelopes() { - const existingEnvelopes = this.mainStore.getEnvelopes(this.mailbox.databaseId, this.searchQuery || '') + const existingEnvelopes = this.mainStore.getEnvelopes(this.mailbox.databaseId, this.query) if (!existingEnvelopes.length) { await this.mainStore.fetchEnvelopes({ mailboxId: this.mailbox.databaseId, - query: this.searchQuery || '', + query: this.query, }) } }, diff --git a/src/store/mainStore/actions.js b/src/store/mainStore/actions.js index 96135f3bc3..f037b5bc48 100644 --- a/src/store/mainStore/actions.js +++ b/src/store/mainStore/actions.js @@ -804,7 +804,15 @@ export default function mainStoreActions() { return Promise.reject(new Error('Cannot find last envelope. Required for the mailbox cursor')) } - return fetchEnvelopes(mailbox.accountId, mailboxId, query, lastEnvelope.dateInt, quantity, this.getPreference('sort-order')).then((envelopes) => { + return fetchEnvelopes( + mailbox.accountId, + mailboxId, + query, + lastEnvelope.dateInt, + quantity, + this.getPreference('sort-order'), + this.getPreference('layout-message-view'), + ).then((envelopes) => { logger.debug(`fetched ${envelopes.length} messages for mailbox ${mailboxId}`, { envelopes, addToUnifiedMailboxes, diff --git a/src/tests/unit/store/actions.spec.js b/src/tests/unit/store/actions.spec.js index d6bdc4e3dd..025060a452 100644 --- a/src/tests/unit/store/actions.spec.js +++ b/src/tests/unit/store/actions.spec.js @@ -204,6 +204,7 @@ describe('Vuex store actions', () => { } store.preferences['sort-order'] = 'newest' + store.preferences['layout-message-view'] = 'threaded' store.addAccountMutation(account13) store.addMailboxMutation({ @@ -245,7 +246,7 @@ describe('Vuex store actions', () => { expect(MessageService.fetchEnvelopes).toHaveBeenCalledTimes(1) expect(MessageService.fetchEnvelopes) - .toHaveBeenNthCalledWith(1, 13, 11, undefined, 300000, PAGE_SIZE, 'newest') + .toHaveBeenNthCalledWith(1, 13, 11, undefined, 300000, PAGE_SIZE, 'newest', 'threaded') expect(store.mailboxes[UNIFIED_INBOX_ID].envelopeLists[''].toSorted()).toEqual([ // Initial envelopes ...msgs1.map(mockEnvelope(11)), @@ -335,6 +336,7 @@ describe('Vuex store actions', () => { } store.preferences['sort-order'] = 'newest' + store.preferences['layout-message-view'] = 'threaded' store.addAccountMutation(account13) store.addAccountMutation(account26) @@ -403,9 +405,9 @@ describe('Vuex store actions', () => { expect(MessageService.fetchEnvelopes).toHaveBeenCalledTimes(2) expect(MessageService.fetchEnvelopes) - .toHaveBeenNthCalledWith(1, 13, 11, undefined, 300000, PAGE_SIZE, 'newest') + .toHaveBeenNthCalledWith(1, 13, 11, undefined, 300000, PAGE_SIZE, 'newest', 'threaded') expect(MessageService.fetchEnvelopes) - .toHaveBeenNthCalledWith(2, 26, 21, undefined, 600000, PAGE_SIZE, 'newest') + .toHaveBeenNthCalledWith(2, 26, 21, undefined, 600000, PAGE_SIZE, 'newest', 'threaded') expect(store.mailboxes[UNIFIED_INBOX_ID].envelopeLists[''].toSorted()).toEqual([ // Initial envelopes ...page1.map(mockEnvelope(11)),