run user repo call in coroutine

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-06-20 13:28:16 +02:00
parent 349d5fe19b
commit 75c8625aee
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B

View file

@ -58,7 +58,6 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ACTIVE_CONVERSATION
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_ID import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_ID
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY
import com.nextcloud.talk.utils.database.user.UserUtils
import io.reactivex.Observer import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
@ -66,6 +65,9 @@ import io.reactivex.schedulers.Schedulers
import io.requery.Persistable import io.requery.Persistable
import io.requery.android.sqlcipher.SqlCipherDatabaseSource import io.requery.android.sqlcipher.SqlCipherDatabaseSource
import io.requery.reactivex.ReactiveEntityStore import io.requery.reactivex.ReactiveEntityStore
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.parceler.Parcels import org.parceler.Parcels
import javax.inject.Inject import javax.inject.Inject
@ -115,10 +117,16 @@ class MainActivity : BaseActivity(), ActionBarProvider {
onNewIntent(intent) onNewIntent(intent)
} else if (!router!!.hasRootController()) { } else if (!router!!.hasRootController()) {
if (hasDb) { if (hasDb) {
if (usersRepository.getUsers().isNotEmpty()) { GlobalScope.launch {
setDefaultRootController() if (usersRepository.getUsers().isNotEmpty()) {
} else { runOnUiThread {
launchLoginScreen() setDefaultRootController()
}
} else {
runOnUiThread {
launchLoginScreen()
}
}
} }
} else { } else {
launchLoginScreen() launchLoginScreen()