1
0
Fork 0

For #2395 - Adds an early return statement and documents why we copy a feature

master
Jeff Boek 2019-06-05 09:52:19 -07:00
parent e7e644f07e
commit 27fdd9605b
2 changed files with 12 additions and 1 deletions

View File

@ -11,6 +11,12 @@ import mozilla.components.service.fxa.manager.FxaAccountManager
import org.mozilla.fenix.settings.SupportUtils
import kotlin.coroutines.CoroutineContext
// The FirefoxAccountsAuthFeature provided by android components only worked with
// the tabs use case. We want to use our custom tab feature to improve the UX for both
// signing in through settings and onboarding.
// We're temporarily copying and creating our own:
// https://github.com/mozilla-mobile/android-components/issues/3272
class FirefoxAccountsAuthFeature(
private val accountManager: FxaAccountManager,
private val redirectUrl: String,
@ -32,7 +38,7 @@ class FirefoxAccountsAuthFeature(
CoroutineScope(coroutineContext).launch {
// FIXME return a fallback URL provided by Config...
// https://github.com/mozilla-mobile/android-components/issues/2496
val authUrl = beginAuthentication() ?: "https://accounts.firefox.com/signin"
val authUrl = beginAuthentication() ?: FALLBACK_URL
// TODO
// We may fail to obtain an authentication URL, for example due to transient network errors.
@ -64,4 +70,8 @@ class FirefoxAccountsAuthFeature(
return null
}
}
companion object {
private const val FALLBACK_URL = "https://accounts.firefox.com/signin"
}
}

View File

@ -35,6 +35,7 @@ class TurnOnSyncFragment : PreferenceFragmentCompat(), AccountObserver {
super.onResume()
if (requireComponents.backgroundServices.accountManager.authenticatedAccount() != null) {
findNavController(this).popBackStack()
return
}
requireComponents.backgroundServices.accountManager.register(this, owner = this)