From 880a73b855eaa4859c57a410721b6db235ea314b Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Wed, 25 Sep 2024 19:12:15 +0530 Subject: [PATCH] fixed crash happening on the fetching config --- .../kotlin/com/alfresco/content/data/CommonRepository.kt | 8 ++++++-- .../com/alfresco/content/data/MobileConfigDataEntry.kt | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/data/src/main/kotlin/com/alfresco/content/data/CommonRepository.kt b/data/src/main/kotlin/com/alfresco/content/data/CommonRepository.kt index d51bc464..36b290a0 100644 --- a/data/src/main/kotlin/com/alfresco/content/data/CommonRepository.kt +++ b/data/src/main/kotlin/com/alfresco/content/data/CommonRepository.kt @@ -51,8 +51,12 @@ class CommonRepository(val session: Session = SessionManager.requireSession) { } suspend fun getMobileConfigData() { - val data = MobileConfigDataEntry.with(service.getMobileConfig("https://${URL(session.account.serverUrl).host}/app-config.json")) - + var data = MobileConfigDataEntry.default() + try { + data = MobileConfigDataEntry.with(service.getMobileConfig("https://${URL(session.account.serverUrl).host}/app-config.json")) + } catch (ex: Exception) { + ex.printStackTrace() + } saveJsonToSharedPrefs(session.context, KEY_FEATURES_MOBILE, data) } diff --git a/data/src/main/kotlin/com/alfresco/content/data/MobileConfigDataEntry.kt b/data/src/main/kotlin/com/alfresco/content/data/MobileConfigDataEntry.kt index 78427485..c7ab06a0 100644 --- a/data/src/main/kotlin/com/alfresco/content/data/MobileConfigDataEntry.kt +++ b/data/src/main/kotlin/com/alfresco/content/data/MobileConfigDataEntry.kt @@ -18,6 +18,10 @@ data class MobileConfigDataEntry( featuresMobile = MobileFeatures.with(configData.featuresMobile), ) } + + fun default(): MobileConfigDataEntry { + return MobileConfigDataEntry(featuresMobile = MobileFeatures()) + } } }