Bug 1884487 – simplify NavbarIntegration by removing viewLifecycleOwner

fenix/125.0
mike a 2 months ago committed by mergify[bot]
parent ab304c5f9d
commit 1d0cc1ad52

@ -480,7 +480,6 @@ abstract class BaseBrowserFragment :
toolbar = bottomToolbarContainerView.toolbarContainerView, toolbar = bottomToolbarContainerView.toolbarContainerView,
store = requireComponents.core.store, store = requireComponents.core.store,
appStore = requireComponents.appStore, appStore = requireComponents.appStore,
viewLifecycleOwner = viewLifecycleOwner,
bottomToolbarContainerView = bottomToolbarContainerView, bottomToolbarContainerView = bottomToolbarContainerView,
sessionId = customTabSessionId, sessionId = customTabSessionId,
), ),

@ -6,7 +6,6 @@ package org.mozilla.fenix.components.toolbar.navbar
import androidx.annotation.VisibleForTesting import androidx.annotation.VisibleForTesting
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.lifecycle.LifecycleOwner
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.cancel import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.distinctUntilChangedBy import kotlinx.coroutines.flow.distinctUntilChangedBy
@ -26,19 +25,18 @@ class NavbarIntegration(
val toolbar: ScrollableToolbar, val toolbar: ScrollableToolbar,
val store: BrowserStore, val store: BrowserStore,
val appStore: AppStore, val appStore: AppStore,
val viewLifecycleOwner: LifecycleOwner,
val bottomToolbarContainerView: BottomToolbarContainerView, val bottomToolbarContainerView: BottomToolbarContainerView,
sessionId: String?, sessionId: String?,
) : LifecycleAwareFeature { ) : LifecycleAwareFeature {
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
var toolbarController = ToolbarBehaviorController(toolbar, store, sessionId) var toolbarController = ToolbarBehaviorController(toolbar, store, sessionId)
var scope: CoroutineScope? = null private var scope: CoroutineScope? = null
override fun start() { override fun start() {
toolbarController.start() toolbarController.start()
scope = appStore.flowScoped(viewLifecycleOwner) { flow -> scope = appStore.flowScoped { flow ->
flow.distinctUntilChangedBy { it.isSearchDialogVisible } flow.distinctUntilChangedBy { it.isSearchDialogVisible }
.collect { state -> .collect { state ->
bottomToolbarContainerView.composeView.isVisible = !state.isSearchDialogVisible bottomToolbarContainerView.composeView.isVisible = !state.isSearchDialogVisible

@ -476,7 +476,6 @@ class HomeFragment : Fragment() {
toolbar = bottomToolbarContainerView.toolbarContainerView, toolbar = bottomToolbarContainerView.toolbarContainerView,
store = requireComponents.core.store, store = requireComponents.core.store,
appStore = requireComponents.appStore, appStore = requireComponents.appStore,
viewLifecycleOwner = viewLifecycleOwner,
bottomToolbarContainerView = bottomToolbarContainerView, bottomToolbarContainerView = bottomToolbarContainerView,
sessionId = null, sessionId = null,
), ),

@ -22,7 +22,6 @@ class NavbarIntegrationTest {
toolbar = mockk(), toolbar = mockk(),
store = mockk(), store = mockk(),
appStore = mockk(), appStore = mockk(),
viewLifecycleOwner = mockk(),
bottomToolbarContainerView = mockk(), bottomToolbarContainerView = mockk(),
sessionId = null, sessionId = null,
).apply { ).apply {

Loading…
Cancel
Save