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

For #22226 - Open grouped history entries the same as individual ones #22244

Merged
merged 1 commit into from
Nov 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,17 @@ class HistoryFragment : LibraryPageFragment<History>(), UserInteractionHandler {
return view
}

override val selectedItems get() = historyStore.state.mode.selectedItems
/**
* All the current selected items. Individual history entries and entries from a group.
* When a history group is selected, this will instead contain all the history entries in that group.
*/
override val selectedItems
get() = historyStore.state.mode.selectedItems.fold(emptyList<History>()) { accumulator, item ->
when (item) {
is History.Group -> accumulator + item.items
else -> accumulator + item
}
}.toSet()

private fun invalidateOptionsMenu() {
activity?.invalidateOptionsMenu()
Expand Down Expand Up @@ -206,19 +216,17 @@ class HistoryFragment : LibraryPageFragment<History>(), UserInteractionHandler {
}
R.id.open_history_in_new_tabs_multi_select -> {
openItemsInNewTab { selectedItem ->
selectedItem as History.Regular
requireComponents.analytics.metrics.track(Event.HistoryOpenedInNewTabs)
selectedItem.url
(selectedItem as? History.Regular)?.url ?: (selectedItem as? History.Metadata)?.url
}

showTabTray()
true
}
R.id.open_history_in_private_tabs_multi_select -> {
openItemsInNewTab(private = true) { selectedItem ->
selectedItem as History.Regular
requireComponents.analytics.metrics.track(Event.HistoryOpenedInPrivateTabs)
selectedItem.url
(selectedItem as? History.Regular)?.url ?: (selectedItem as? History.Metadata)?.url
}

(activity as HomeActivity).apply {
Expand Down