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 ...@@ -79,13 +79,13 @@ class RocketChatApplication : Application(), HasActivityInjector, HasServiceInje
setupCrashlytics() setupCrashlytics()
setupFresco() setupFresco()
setupTimber() setupTimber()
startMigrationIfNeeded() migrateFromLegacy()
// TODO - remove this when we have a proper service handling connection... // TODO - remove this when we have a proper service handling connection...
initCurrentServer() initCurrentServer()
} }
private fun startMigrationIfNeeded() { private fun migrateFromLegacy() {
Realm.init(this) Realm.init(this)
val serveListConfiguration = RealmConfiguration.Builder() val serveListConfiguration = RealmConfiguration.Builder()
.name("server.list.realm") .name("server.list.realm")
......
...@@ -15,9 +15,7 @@ class SharedPreferencesSettingsRepository(private val localRepository: LocalRepo ...@@ -15,9 +15,7 @@ class SharedPreferencesSettingsRepository(private val localRepository: LocalRepo
} }
override fun get(url: String): PublicSettings { override fun get(url: String): PublicSettings {
val settings = localRepository.get("$SETTINGS_KEY$url")!! val settings = localRepository.get("$SETTINGS_KEY$url")
settings.let { return if (settings == null) hashMapOf() else adapter.fromJson(settings) ?: hashMapOf()
return adapter.fromJson(it)!!
}
} }
} }
\ 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