Commit a43b7c89 authored by Lucio Maciel's avatar Lucio Maciel

Save to TokenRepository and guard with try/catch

parent 15bbe966
...@@ -91,7 +91,14 @@ class RocketChatApplication : Application(), HasActivityInjector, HasServiceInje ...@@ -91,7 +91,14 @@ class RocketChatApplication : Application(), HasActivityInjector, HasServiceInje
setupCrashlytics() setupCrashlytics()
setupFresco() setupFresco()
setupTimber() setupTimber()
migrateFromLegacy()
// TODO - remove this and all realm stuff when we got to 80% in 2.0
try {
migrateFromLegacy()
} catch (ex: Exception) {
Timber.d(ex, "Error migrating old accounts")
ex.printStackTrace()
}
} }
private fun migrateFromLegacy() { private fun migrateFromLegacy() {
...@@ -144,8 +151,7 @@ class RocketChatApplication : Application(), HasActivityInjector, HasServiceInje ...@@ -144,8 +151,7 @@ class RocketChatApplication : Application(), HasActivityInjector, HasServiceInje
} }
val account = Account(url, icon, logo, user.username!!, avatar) val account = Account(url, icon, logo, user.username!!, avatar)
launch(CommonPool) { launch(CommonPool) {
val tokenModel = TokenModel(userId!!, authToken) tokenRepository.save(url, Token(userId!!, authToken))
multiServerRepository.save(url, tokenModel)
accountRepository.save(account) accountRepository.save(account)
} }
} }
......
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