From d4ebe5460b8b9e49b08f9d4803a13e77310ffd27 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 22 Aug 2021 20:14:22 +0300 Subject: [PATCH] fall back to any profile when restoring config MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit it would be strange to happen, because the config should always have a current profile, but who knows… defensive programming --- .../net/ktnx/mobileledger/async/ConfigReader.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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); } -- 2.39.2