Fixed limiting local search

pull/180/head
M66B 5 years ago
parent 28526c4ad3
commit 0ce044f76c

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

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

Loading…
Cancel
Save