Batch search fix

pull/164/head
M66B 5 years ago
parent 76f7897489
commit 6e4af2ed03

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

Loading…
Cancel
Save