From: Damyan Ivanov Date: Sun, 22 Aug 2021 17:14:22 +0000 (+0300) Subject: fall back to any profile when restoring config X-Git-Tag: v0.20.0~1 X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=commitdiff_plain;h=d4ebe5460b8b9e49b08f9d4803a13e77310ffd27 fall back to any profile when restoring config it would be strange to happen, because the config should always have a current profile, but who knows… defensive programming --- diff --git a/app/src/main/java/net/ktnx/mobileledger/async/ConfigReader.java b/app/src/main/java/net/ktnx/mobileledger/async/ConfigReader.java index 16b9ac24..bc95a8f8 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/ConfigReader.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/ConfigReader.java @@ -92,10 +92,16 @@ public class ConfigReader extends ConfigIO { restoreProfiles(profiles); restoreTemplates(templates); - if (Data.getProfile() == null && currentProfile != null) { - Profile p = DB.get() - .getProfileDAO() - .getByUuidSync(currentProfile); + if (Data.getProfile() == null) { + Profile p = null; + final ProfileDAO dao = DB.get() + .getProfileDAO(); + if (currentProfile != null) + p = dao.getByUuidSync(currentProfile); + + if (p == null) + dao.getAnySync(); + if (p != null) Data.postCurrentProfile(p); }