diff --git a/app/src/main/java/org/mozilla/fenix/settings/address/AddressManagementFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/address/AddressManagementFragment.kt index 9a1a5ddf032d..25c4edfe71aa 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/address/AddressManagementFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/address/AddressManagementFragment.kt @@ -14,6 +14,7 @@ import androidx.lifecycle.lifecycleScope import androidx.navigation.fragment.findNavController import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import mozilla.components.lib.state.ext.consumeFrom import mozilla.components.lib.state.ext.observeAsComposableState import org.mozilla.fenix.components.StoreProvider import org.mozilla.fenix.ext.components @@ -66,6 +67,15 @@ class AddressManagementFragment : Fragment() { } } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + consumeFrom(store) { state -> + if (!state.isLoading && state.addresses.isEmpty()) { + findNavController().popBackStack() + return@consumeFrom + } + } + } + /** * Fetches all the addresses from the autofill storage and updates the * [AutofillFragmentStore] with the list of addresses.