Fixed limiting local search

This commit is contained in:
M66B 2020-05-27 11:04:36 +02:00
parent 28526c4ad3
commit 0ce044f76c
2 changed files with 16 additions and 8 deletions

View File

@ -229,6 +229,11 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
state.matches = db.message().matchMessages(
account, folder,
criteria.query == null ? null : "%" + criteria.query + "%",
criteria.in_senders,
criteria.in_recipients,
criteria.in_subject,
criteria.in_keywords,
criteria.in_message,
criteria.with_unseen,
criteria.with_flagged,
criteria.with_hidden,
@ -252,7 +257,9 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
state.index = i + 1;
TupleMatch match = state.matches.get(i);
if (criteria.query != null && (match.matched == null || !match.matched))
if (criteria.query != null &&
criteria.in_message &&
(match.matched == null || !match.matched))
try {
File file = EntityMessage.getFile(context, match.id);
if (file.exists()) {

View File

@ -297,13 +297,13 @@ public interface DaoMessage {
Cursor getMessageFts();
@Query("SELECT id, account, thread, (:find IS NULL" +
" OR `from` LIKE :find COLLATE NOCASE" + // no index
" OR `to` LIKE :find COLLATE NOCASE" + // no index
" OR `cc` LIKE :find COLLATE NOCASE" + // no index
" OR `bcc` LIKE :find COLLATE NOCASE" + // no index
" OR `subject` LIKE :find COLLATE NOCASE" + // unsuitable index
" OR `keywords` LIKE :find COLLATE NOCASE" + // no index
" OR `preview` LIKE :find COLLATE NOCASE) AS matched" + // no index
" OR (:senders AND `from` LIKE :find COLLATE NOCASE)" + // no index
" OR (:recipients AND `to` LIKE :find COLLATE NOCASE)" + // no index
" OR (:recipients AND `cc` LIKE :find COLLATE NOCASE)" + // no index
" OR (:recipients AND `bcc` LIKE :find COLLATE NOCASE)" + // no index
" OR (:subject AND `subject` LIKE :find COLLATE NOCASE)" + // unsuitable index
" OR (:keywords AND `keywords` LIKE :find COLLATE NOCASE)" + // no index
" OR (:message AND `preview` LIKE :find COLLATE NOCASE)) AS matched" + // no index
" FROM message" +
" WHERE NOT ui_hide" +
" AND (:account IS NULL OR account = :account)" +
@ -319,6 +319,7 @@ public interface DaoMessage {
" LIMIT :limit OFFSET :offset")
List<TupleMatch> matchMessages(
Long account, Long folder, String find,
boolean senders, boolean recipients, boolean subject, boolean keywords, boolean message,
boolean unseen, boolean flagged, boolean hidden, boolean encrypted, boolean attachments,
Long after, Long before,
int limit, int offset);