Report search error once

pull/147/head
M66B 7 years ago
parent eefe9667ec
commit f355a0a2c8

@ -66,6 +66,7 @@ public class ViewModelBrowse extends ViewModel {
Message[] imessages = null; Message[] imessages = null;
int index = -1; int index = -1;
boolean error = false;
} }
void set(Context context, long folder, String search, int pageSize) { void set(Context context, long folder, String search, int pageSize) {
@ -75,6 +76,7 @@ public class ViewModelBrowse extends ViewModel {
currentState.search = search; currentState.search = search;
currentState.pageSize = pageSize; currentState.pageSize = pageSize;
currentState.index = -1; currentState.index = -1;
currentState.error = false;
} }
boolean isSearching() { boolean isSearching() {
@ -83,8 +85,8 @@ public class ViewModelBrowse extends ViewModel {
} }
void load() throws MessagingException, IOException { void load() throws MessagingException, IOException {
State state = currentState; final State state = currentState;
if (state == null) if (state == null || state.error)
return; return;
DB db = DB.getInstance(state.context); DB db = DB.getInstance(state.context);
@ -157,6 +159,7 @@ public class ViewModelBrowse extends ViewModel {
try { try {
Properties props = MessageHelper.getSessionProperties(account.auth_type, account.realm, account.insecure); Properties props = MessageHelper.getSessionProperties(account.auth_type, account.realm, account.insecure);
Session isession = Session.getInstance(props, null); Session isession = Session.getInstance(props, null);
isession.setDebug(true);
Log.i("Boundary connecting account=" + account.name); Log.i("Boundary connecting account=" + account.name);
state.istore = (IMAPStore) isession.getStore(account.starttls ? "imap" : "imaps"); state.istore = (IMAPStore) isession.getStore(account.starttls ? "imap" : "imaps");
@ -188,11 +191,13 @@ public class ViewModelBrowse extends ViewModel {
} }
state.imessages = state.ifolder.search(term); state.imessages = state.ifolder.search(term);
} }
Log.i("Boundary found messages=" + state.imessages.length); Log.i("Boundary found messages=" + state.imessages.length);
state.index = state.imessages.length - 1; state.index = state.imessages.length - 1;
} catch (Throwable ex) { } catch (Throwable ex) {
state.error = true;
if (ex instanceof FolderClosedException) if (ex instanceof FolderClosedException)
Log.w("Search", ex); Log.w("Search", ex);
else { else {

Loading…
Cancel
Save