1
0
Fork 0

Part 2: Do not eagerly initilize account manager within HomeActivity

Instead of always kicking off accountManager's init and telling it to sync right away in
'onResume', we move these tasks to some abstract point later on, whenever account manager
is available.
master
Grisha Kruglov 2020-03-26 23:18:32 -07:00 committed by Grisha Kruglov
parent 0677fc35de
commit 3efaa516ca
1 changed files with 5 additions and 5 deletions

View File

@ -146,13 +146,13 @@ open class HomeActivity : LocaleAwareAppCompatActivity() {
override fun onResume() {
super.onResume()
lifecycleScope.launch {
with(components.backgroundServices) {
components.backgroundServices.accountManagerAvailableQueue.runIfReadyOrQueue {
lifecycleScope.launch {
// Make sure accountManager is initialized.
accountManager.initAsync().await()
components.backgroundServices.accountManager.initAsync().await()
// If we're authenticated, kick-off a sync and a device state refresh.
accountManager.authenticatedAccount()?.let {
accountManager.syncNowAsync(SyncReason.Startup, debounce = true)
components.backgroundServices.accountManager.authenticatedAccount()?.let {
components.backgroundServices.accountManager.syncNowAsync(SyncReason.Startup, debounce = true)
}
}
}