Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #24966: Navigate back to previous screen when the last address is…
Browse files Browse the repository at this point in the history
… deleted.
  • Loading branch information
mcarare committed May 5, 2022
1 parent 94165f5 commit 9369651
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 9369651

Please sign in to comment.