[fenix] 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.
pull/600/head
Grisha Kruglov 5 years ago committed by Grisha Kruglov
parent 4e308faf35
commit 1a6e1c0b7f

@ -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)
}
}
}

Loading…
Cancel
Save