For #24114 - Refactor ext/HomeFragmentState to ext/AppState

This commit is contained in:
Gabriel Luong 2022-03-06 18:55:11 -05:00 committed by mergify[bot]
parent 1647d93591
commit 09df4dd787
1 changed files with 5 additions and 5 deletions

View File

@ -6,7 +6,7 @@ package org.mozilla.fenix.ext
import androidx.annotation.VisibleForTesting
import mozilla.components.service.pocket.PocketRecommendedStory
import org.mozilla.fenix.home.HomeFragmentState
import org.mozilla.fenix.components.appstate.AppState
import org.mozilla.fenix.home.blocklist.BlocklistHandler
import org.mozilla.fenix.home.pocket.POCKET_STORIES_DEFAULT_CATEGORY_NAME
import org.mozilla.fenix.home.pocket.PocketRecommendedStoriesCategory
@ -20,7 +20,7 @@ import org.mozilla.fenix.home.recenttabs.RecentTab.SearchGroup
*
* @return a list of [PocketRecommendedStory]es from the currently selected categories.
*/
fun HomeFragmentState.getFilteredStories(
fun AppState.getFilteredStories(
neededStoriesCount: Int
): List<PocketRecommendedStory> {
if (pocketStoriesCategoriesSelections.isEmpty()) {
@ -99,15 +99,15 @@ internal fun getFilteredStoriesCount(
* Get the [SearchGroup] shown in the "Jump back in" section.
* May be null if no search group is shown.
*/
internal val HomeFragmentState.recentSearchGroup: SearchGroup?
internal val AppState.recentSearchGroup: SearchGroup?
get() = recentTabs.find { it is SearchGroup } as SearchGroup?
/**
* Filter a [HomeFragmentState] by the blocklist.
* Filter a [AppState] by the blocklist.
*
* @param blocklistHandler The handler that will filter the state.
*/
fun HomeFragmentState.filterState(blocklistHandler: BlocklistHandler): HomeFragmentState =
fun AppState.filterState(blocklistHandler: BlocklistHandler): AppState =
with(blocklistHandler) {
copy(
recentBookmarks = recentBookmarks.filteredByBlocklist(),