[fenix] For https://github.com/mozilla-mobile/fenix/issues/24966: Navigate back to previous screen when the last address is deleted.

pull/600/head
mcarare 2 years ago committed by mergify[bot]
parent 785b88334c
commit c7115455e4

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

Loading…
Cancel
Save