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.
fennec/production
Grisha Kruglov 4 years ago committed by Grisha Kruglov
parent 0677fc35de
commit 3efaa516ca

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