Skip to content

Commit e3394d1

Browse files
committed
fix(search): apply correct search query when fetching envelopes
Signed-off-by: Daniel Kesselberg <[email protected]>
1 parent 37da2d2 commit e3394d1

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

src/components/MailboxThread.vue

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ export default {
260260
return this.mainStore.getEnvelopes(this.mailbox.databaseId, this.appendToSearch(priorityImportantQuery)).length > 0
261261
|| this.mainStore.getEnvelopes(this.mailbox.databaseId, this.appendToSearch(priorityOtherQuery)).length > 0
262262
}
263-
return this.mainStore.getEnvelopes(this.mailbox.databaseId, this.searchQuery).length > 0
263+
return this.mainStore.getEnvelopes(this.mailbox.databaseId, this.query).length > 0
264264
},
265265
266266
hasImportantEnvelopes() {
@@ -316,10 +316,7 @@ export default {
316316
317317
query() {
318318
if (this.$route.params.filter === 'starred') {
319-
if (this.searchQuery) {
320-
return this.appendToSearch('is:starred')
321-
}
322-
return 'is:starred'
319+
return this.appendToSearch('is:starred')
323320
}
324321
return this.searchQuery
325322
},
@@ -329,7 +326,7 @@ export default {
329326
},
330327
331328
groupEnvelopes() {
332-
const allEnvelopes = this.mainStore.getEnvelopes(this.mailbox.databaseId, this.searchQuery)
329+
const allEnvelopes = this.mainStore.getEnvelopes(this.mailbox.databaseId, this.query)
333330
return this.getGroupedEnvelopes(allEnvelopes, this.mainStore.syncTimestamp, this.sortOrder)
334331
},
335332
@@ -384,11 +381,11 @@ export default {
384381
},
385382
386383
async fetchEnvelopes() {
387-
const existingEnvelopes = this.mainStore.getEnvelopes(this.mailbox.databaseId, this.searchQuery || '')
384+
const existingEnvelopes = this.mainStore.getEnvelopes(this.mailbox.databaseId, this.query)
388385
if (!existingEnvelopes.length) {
389386
await this.mainStore.fetchEnvelopes({
390387
mailboxId: this.mailbox.databaseId,
391-
query: this.searchQuery || '',
388+
query: this.query,
392389
})
393390
}
394391
},

src/store/mainStore/actions.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,15 @@ export default function mainStoreActions() {
804804
return Promise.reject(new Error('Cannot find last envelope. Required for the mailbox cursor'))
805805
}
806806

807-
return fetchEnvelopes(mailbox.accountId, mailboxId, query, lastEnvelope.dateInt, quantity, this.getPreference('sort-order')).then((envelopes) => {
807+
return fetchEnvelopes(
808+
mailbox.accountId,
809+
mailboxId,
810+
query,
811+
lastEnvelope.dateInt,
812+
quantity,
813+
this.getPreference('sort-order'),
814+
this.getPreference('layout-message-view'),
815+
).then((envelopes) => {
808816
logger.debug(`fetched ${envelopes.length} messages for mailbox ${mailboxId}`, {
809817
envelopes,
810818
addToUnifiedMailboxes,

src/tests/unit/store/actions.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ describe('Vuex store actions', () => {
204204
}
205205

206206
store.preferences['sort-order'] = 'newest'
207+
store.preferences['layout-message-view'] = 'threaded'
207208

208209
store.addAccountMutation(account13)
209210
store.addMailboxMutation({
@@ -245,7 +246,7 @@ describe('Vuex store actions', () => {
245246

246247
expect(MessageService.fetchEnvelopes).toHaveBeenCalledTimes(1)
247248
expect(MessageService.fetchEnvelopes)
248-
.toHaveBeenNthCalledWith(1, 13, 11, undefined, 300000, PAGE_SIZE, 'newest')
249+
.toHaveBeenNthCalledWith(1, 13, 11, undefined, 300000, PAGE_SIZE, 'newest', 'threaded')
249250
expect(store.mailboxes[UNIFIED_INBOX_ID].envelopeLists[''].toSorted()).toEqual([
250251
// Initial envelopes
251252
...msgs1.map(mockEnvelope(11)),
@@ -335,6 +336,7 @@ describe('Vuex store actions', () => {
335336
}
336337

337338
store.preferences['sort-order'] = 'newest'
339+
store.preferences['layout-message-view'] = 'threaded'
338340

339341
store.addAccountMutation(account13)
340342
store.addAccountMutation(account26)
@@ -403,9 +405,9 @@ describe('Vuex store actions', () => {
403405

404406
expect(MessageService.fetchEnvelopes).toHaveBeenCalledTimes(2)
405407
expect(MessageService.fetchEnvelopes)
406-
.toHaveBeenNthCalledWith(1, 13, 11, undefined, 300000, PAGE_SIZE, 'newest')
408+
.toHaveBeenNthCalledWith(1, 13, 11, undefined, 300000, PAGE_SIZE, 'newest', 'threaded')
407409
expect(MessageService.fetchEnvelopes)
408-
.toHaveBeenNthCalledWith(2, 26, 21, undefined, 600000, PAGE_SIZE, 'newest')
410+
.toHaveBeenNthCalledWith(2, 26, 21, undefined, 600000, PAGE_SIZE, 'newest', 'threaded')
409411
expect(store.mailboxes[UNIFIED_INBOX_ID].envelopeLists[''].toSorted()).toEqual([
410412
// Initial envelopes
411413
...page1.map(mockEnvelope(11)),

0 commit comments

Comments
 (0)