Commit 801f6da3 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Add a null-check on fetching settings

parent a9ebf737
......@@ -79,13 +79,13 @@ class RocketChatApplication : Application(), HasActivityInjector, HasServiceInje
setupCrashlytics()
setupFresco()
setupTimber()
startMigrationIfNeeded()
migrateFromLegacy()
// TODO - remove this when we have a proper service handling connection...
initCurrentServer()
}
private fun startMigrationIfNeeded() {
private fun migrateFromLegacy() {
Realm.init(this)
val serveListConfiguration = RealmConfiguration.Builder()
.name("server.list.realm")
......
......@@ -15,9 +15,7 @@ class SharedPreferencesSettingsRepository(private val localRepository: LocalRepo
}
override fun get(url: String): PublicSettings {
val settings = localRepository.get("$SETTINGS_KEY$url")!!
settings.let {
return adapter.fromJson(it)!!
}
val settings = localRepository.get("$SETTINGS_KEY$url")
return if (settings == null) hashMapOf() else adapter.fromJson(settings) ?: hashMapOf()
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment