Batch search fix

This commit is contained in:
M66B 2019-10-29 11:34:03 +01:00
parent 76f7897489
commit 6e4af2ed03
1 changed files with 20 additions and 16 deletions

View File

@ -181,6 +181,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
db.beginTransaction();
while (found < pageSize && !state.destroyed) {
if (state.matches == null ||
(state.matches.size() > 0 && state.index >= state.matches.size())) {
state.matches = db.message().matchMessages(
folder,
"%" + find + "%",
@ -196,6 +198,10 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
if (state.matches.size() == 0)
break;
state.offset += Math.min(state.matches.size(), SEARCH_LIMIT);
state.index = 0;
}
for (int i = state.index; i < state.matches.size() && found < pageSize && !state.destroyed; i++) {
state.index = i + 1;
@ -223,8 +229,6 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
db.message().setMessageFound(match.account, match.thread);
}
}
state.offset += SEARCH_LIMIT;
}
db.setTransactionSuccessful();