From 872984b33ca35de0b1ccdb3a9e1e4045822abad6 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 17 Mar 2019 18:12:53 +0000 Subject: [PATCH] Fixed initial state --- .../eu/faircode/email/ServiceSynchronize.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index c04e82f748..675e1519fc 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1153,14 +1153,6 @@ public class ServiceSynchronize extends LifecycleService { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); prefs.edit().remove("oneshot").apply(); - for (EntityAccount account : db.account().getAccounts()) - db.account().setAccountState(account.id, null); - - for (EntityFolder folder : db.folder().getFolders()) { - db.folder().setFolderState(folder.id, null); - db.folder().setFolderSyncState(folder.id, null); - } - // Restore snooze timers for (EntityMessage message : db.message().getSnoozed()) EntityMessage.snooze(context, message.id, message.ui_snoozed); @@ -1175,6 +1167,15 @@ public class ServiceSynchronize extends LifecycleService { ContextCompat.startForegroundService(context, new Intent(context, ServiceSynchronize.class) .setAction("init")); + else { + for (EntityAccount account : db.account().getAccounts()) + db.account().setAccountState(account.id, null); + + for (EntityFolder folder : db.folder().getFolders()) { + db.folder().setFolderState(folder.id, null); + db.folder().setFolderSyncState(folder.id, null); + } + } } catch (Throwable ex) { Log.e(ex); }