1
0
Fork 0

Part 4: Make sure 'sync is on' snackbar does not initialize account manager

master
Grisha Kruglov 2020-03-30 09:48:12 -07:00 committed by Grisha Kruglov
parent eb98df4edd
commit 029fae4559
1 changed files with 17 additions and 11 deletions

View File

@ -391,19 +391,25 @@ class HomeFragment : Fragment() {
) )
) )
requireComponents.backgroundServices.accountManager.register(currentMode, owner = this) requireComponents.backgroundServices.accountManagerAvailableQueue.runIfReadyOrQueue {
requireComponents.backgroundServices.accountManager.register(object : AccountObserver { // By the time this code runs, we may not be attached to a context.
override fun onAuthenticated(account: OAuthAccount, authType: AuthType) { if ((this@HomeFragment).context == null) {
if (authType != AuthType.Existing) { return@runIfReadyOrQueue
view?.let { }
FenixSnackbar.make(it, Snackbar.LENGTH_SHORT) requireComponents.backgroundServices.accountManager.register(currentMode, owner = this@HomeFragment)
.setText(it.context.getString(R.string.onboarding_firefox_account_sync_is_on)) requireComponents.backgroundServices.accountManager.register(object : AccountObserver {
.setAnchorView(toolbarLayout) override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
.show() if (authType != AuthType.Existing) {
view?.let {
FenixSnackbar.make(it, Snackbar.LENGTH_SHORT)
.setText(it.context.getString(R.string.onboarding_firefox_account_sync_is_on))
.setAnchorView(toolbarLayout)
.show()
}
} }
} }
} }, owner = this@HomeFragment)
}, owner = this) }
if (context.settings().showPrivateModeContextualFeatureRecommender && if (context.settings().showPrivateModeContextualFeatureRecommender &&
browsingModeManager.mode.isPrivate browsingModeManager.mode.isPrivate