From b2d6424011a1b88049d698a48d9fe73e2585798d Mon Sep 17 00:00:00 2001 From: greta Date: Wed, 17 Jun 2026 12:25:57 +0200 Subject: [PATCH 1/3] fix: save correctly any match when closing search modal Signed-off-by: greta --- src/components/SearchMessages.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/SearchMessages.vue b/src/components/SearchMessages.vue index c5b8a8cbff..a4951faa2d 100644 --- a/src/components/SearchMessages.vue +++ b/src/components/SearchMessages.vue @@ -480,6 +480,12 @@ export default { watch: { query() { if (this.query.length === 0) { + this.searchInFrom = [] + this.searchInTo = [] + this.searchInSubject = null + this.searchInMessageBody = null + this.match = 'allof' + this.debouncedSearchQuery() return } @@ -564,7 +570,9 @@ export default { closeSearchModal() { this.moreSearchActions = false - this.match = 'allof' + if (this.query.length === 0) { + this.match = 'allof' + } this.$nextTick(() => { this.sendQueryEvent() }) From 50cf0ea4062a05d40be1bf1019f82eeb501f0f80 Mon Sep 17 00:00:00 2001 From: greta Date: Wed, 17 Jun 2026 15:39:48 +0200 Subject: [PATCH 2/3] fixup! fix: save correctly any match when closing search modal Signed-off-by: greta --- lib/Service/Search/MailSearch.php | 7 ++++++- src/components/SearchMessages.vue | 12 ++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/Service/Search/MailSearch.php b/lib/Service/Search/MailSearch.php index 16f8ada442..5c9279b9aa 100644 --- a/lib/Service/Search/MailSearch.php +++ b/lib/Service/Search/MailSearch.php @@ -150,7 +150,7 @@ public function findMessagesGlobally( * @throws ServiceException */ private function getIdsLocally(Account $account, Mailbox $mailbox, SearchQuery $query, string $sortOrder, ?int $limit): array { - if (empty($query->getBodies())) { + if (empty($query->getBodies()) || !$account->getMailAccount()->getSearchBody()) { return $this->messageMapper->findIdsByQuery($mailbox, $query, $sortOrder, $limit); } @@ -159,6 +159,11 @@ private function getIdsLocally(Account $account, Mailbox $mailbox, SearchQuery $ $mailbox, $query ); + + if (empty($fromImap)) { + return $this->messageMapper->findIdsByQuery($mailbox, $query, $sortOrder, $limit); + } + return $this->messageMapper->findIdsByQuery($mailbox, $query, $sortOrder, $limit, $fromImap); } diff --git a/src/components/SearchMessages.vue b/src/components/SearchMessages.vue index a4951faa2d..eb37d9f0fe 100644 --- a/src/components/SearchMessages.vue +++ b/src/components/SearchMessages.vue @@ -480,17 +480,11 @@ export default { watch: { query() { if (this.query.length === 0) { - this.searchInFrom = [] - this.searchInTo = [] - this.searchInSubject = null - this.searchInMessageBody = null - this.match = 'allof' - this.debouncedSearchQuery() return } this.match = 'anyof' - this.searchInMessageBody = this.searchBody ? this.query : null + this.searchInMessageBody = this.query this.searchInSubject = this.query this.searchInFrom = [{ email: this.query, label: this.query }] this.searchInTo = [{ email: this.query, label: this.query }] @@ -570,9 +564,7 @@ export default { closeSearchModal() { this.moreSearchActions = false - if (this.query.length === 0) { - this.match = 'allof' - } + this.match = 'allof' this.$nextTick(() => { this.sendQueryEvent() }) From 621b48f84585903cc4dbdf3d12b3a65c11362b80 Mon Sep 17 00:00:00 2001 From: greta Date: Thu, 25 Jun 2026 11:33:37 +0200 Subject: [PATCH 3/3] fixup! fix: save correctly any match when closing search modal Signed-off-by: greta --- lib/Db/MessageMapper.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Db/MessageMapper.php b/lib/Db/MessageMapper.php index 4aece97fd3..0374992bdc 100644 --- a/lib/Db/MessageMapper.php +++ b/lib/Db/MessageMapper.php @@ -928,9 +928,10 @@ public function findIdsByQuery(Mailbox $mailbox, SearchQuery $query, string $sor } // createParameter if ($uids !== null) { - // In the case of body+subject search we need a combination of both results, - // thus the orWhere in every other case andWhere should do the job. - if (!empty($query->getSubjects())) { + // In anyof mode or when subjects are also searched, body results must be + // OR'd with other criteria so a match in any one field is sufficient. + // In allof mode without subjects, AND is correct: all criteria must match. + if (!empty($query->getSubjects()) || $query->getMatch() === 'anyof') { $textOrs[] = $qb->expr()->in('m.uid', $qb->createParameter('uids')); } else { $select->andWhere(