mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
Bug 1854709 - Add Store actions for remaining History interactor calls
This commit is contained in:
parent
c403789ab4
commit
1020af9827
@ -159,6 +159,11 @@ sealed class HistoryFragmentAction : Action {
|
|||||||
*/
|
*/
|
||||||
object BackPressed : HistoryFragmentAction()
|
object BackPressed : HistoryFragmentAction()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The search menu item has been clicked.
|
||||||
|
*/
|
||||||
|
object SearchClicked : HistoryFragmentAction()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the empty state of [org.mozilla.fenix.library.history.HistoryView].
|
* Updates the empty state of [org.mozilla.fenix.library.history.HistoryView].
|
||||||
*/
|
*/
|
||||||
@ -281,6 +286,7 @@ private fun historyStateReducer(
|
|||||||
is HistoryFragmentAction.DeleteItems,
|
is HistoryFragmentAction.DeleteItems,
|
||||||
is HistoryFragmentAction.DeleteTimeRange,
|
is HistoryFragmentAction.DeleteTimeRange,
|
||||||
is HistoryFragmentAction.EnterRecentlyClosed,
|
is HistoryFragmentAction.EnterRecentlyClosed,
|
||||||
|
is HistoryFragmentAction.SearchClicked,
|
||||||
-> state
|
-> state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import kotlinx.coroutines.launch
|
|||||||
import mozilla.components.lib.state.Middleware
|
import mozilla.components.lib.state.Middleware
|
||||||
import mozilla.components.lib.state.MiddlewareContext
|
import mozilla.components.lib.state.MiddlewareContext
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.ext.navigateSafe
|
||||||
import org.mozilla.fenix.library.history.History
|
import org.mozilla.fenix.library.history.History
|
||||||
import org.mozilla.fenix.library.history.HistoryFragmentAction
|
import org.mozilla.fenix.library.history.HistoryFragmentAction
|
||||||
import org.mozilla.fenix.library.history.HistoryFragmentDirections
|
import org.mozilla.fenix.library.history.HistoryFragmentDirections
|
||||||
@ -72,6 +73,12 @@ class HistoryNavigationMiddleware(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
is HistoryFragmentAction.SearchClicked -> {
|
||||||
|
navController.navigateSafe(
|
||||||
|
R.id.historyFragment,
|
||||||
|
HistoryFragmentDirections.actionGlobalSearchDialog(null),
|
||||||
|
)
|
||||||
|
}
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,11 @@ class HistoryListItemViewHolder(
|
|||||||
contentDescription = view.context.getString(R.string.history_delete_item)
|
contentDescription = view.context.getString(R.string.history_delete_item)
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
val item = item ?: return@setOnClickListener
|
val item = item ?: return@setOnClickListener
|
||||||
historyInteractor.onDeleteSome(setOf(item))
|
if (FeatureFlags.historyFragmentLibStateRefactor) {
|
||||||
|
store.dispatch(HistoryFragmentAction.DeleteItems(setOf(item)))
|
||||||
|
} else {
|
||||||
|
historyInteractor.onDeleteSome(setOf(item))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import org.junit.Rule
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.ext.navigateSafe
|
||||||
import org.mozilla.fenix.library.history.History
|
import org.mozilla.fenix.library.history.History
|
||||||
import org.mozilla.fenix.library.history.HistoryFragmentAction
|
import org.mozilla.fenix.library.history.HistoryFragmentAction
|
||||||
import org.mozilla.fenix.library.history.HistoryFragmentDirections
|
import org.mozilla.fenix.library.history.HistoryFragmentDirections
|
||||||
@ -168,4 +169,23 @@ class HistoryNavigationMiddlewareTest {
|
|||||||
|
|
||||||
assertTrue(onBackPressed)
|
assertTrue(onBackPressed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `WHEN search is clicked THEN search navigated to`() = runTest {
|
||||||
|
val navController = mock<NavController>()
|
||||||
|
val middleware = HistoryNavigationMiddleware(
|
||||||
|
navController = navController,
|
||||||
|
openToBrowser = { },
|
||||||
|
onBackPressed = { },
|
||||||
|
scope = this,
|
||||||
|
)
|
||||||
|
|
||||||
|
val store =
|
||||||
|
HistoryFragmentStore(HistoryFragmentState.initial, middleware = listOf(middleware))
|
||||||
|
|
||||||
|
store.dispatch(HistoryFragmentAction.SearchClicked).joinBlocking()
|
||||||
|
advanceUntilIdle()
|
||||||
|
|
||||||
|
verify(navController).navigateSafe(R.id.historyFragment, HistoryFragmentDirections.actionGlobalSearchDialog(null))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user