For #25025 - Rename PocketStoriesChange to PocketStoriesClean
PocketStoriesChange was called only once - to clean the shown stories when the user gets to the homescreen and the Pocket feature is disabled - useful for the situations in which the user returns after disabling the feature in settings. Populating the store with recommended stories to show was already happening based on 'PocketStoriesCategoriesChange' and sponsored stories will be added by using 'PocketSponsoredStoriesChange' so renaming 'PocketStoriesChange' will help on reducing any confusion in the future. Also added documentation for all Pocket related actions from AppStore and removed the 'UndocumentedPublicClass' detekt suppressions.
This commit is contained in:
parent
bd1feeaac9
commit
06d4384c11
|
@ -9,7 +9,6 @@ import mozilla.components.feature.top.sites.TopSite
|
|||
import mozilla.components.lib.crash.Crash.NativeCodeCrash
|
||||
import mozilla.components.lib.state.Action
|
||||
import mozilla.components.service.pocket.PocketStory
|
||||
import mozilla.components.service.pocket.PocketStory.PocketRecommendedStory
|
||||
import mozilla.components.service.pocket.PocketStory.PocketSponsoredStory
|
||||
import org.mozilla.fenix.components.AppStore
|
||||
import org.mozilla.fenix.home.Mode
|
||||
|
@ -56,10 +55,22 @@ sealed class AppAction : Action {
|
|||
data class RecentHistoryChange(val recentHistory: List<RecentlyVisitedItem>) : AppAction()
|
||||
data class RemoveRecentHistoryHighlight(val highlightUrl: String) : AppAction()
|
||||
data class DisbandSearchGroupAction(val searchTerm: String) : AppAction()
|
||||
/**
|
||||
* Indicates the given [categoryName] was selected by the user.
|
||||
*/
|
||||
data class SelectPocketStoriesCategory(val categoryName: String) : AppAction()
|
||||
/**
|
||||
* Indicates the given [categoryName] was deselected by the user.
|
||||
*/
|
||||
data class DeselectPocketStoriesCategory(val categoryName: String) : AppAction()
|
||||
/**
|
||||
* Indicates the given [storiesShown] were seen by the user.
|
||||
*/
|
||||
data class PocketStoriesShown(val storiesShown: List<PocketStory>) : AppAction()
|
||||
data class PocketStoriesChange(val pocketStories: List<PocketRecommendedStory>) : AppAction()
|
||||
/**
|
||||
* Cleans all in-memory data about Pocket stories and categories.
|
||||
*/
|
||||
object PocketStoriesClean : AppAction()
|
||||
/**
|
||||
* Replaces the current list of Pocket sponsored stories.
|
||||
*/
|
||||
|
@ -72,8 +83,14 @@ sealed class AppAction : Action {
|
|||
* Removes a set of items, previously marked for removal, to be displayed again in the UI.
|
||||
*/
|
||||
data class UndoPendingDeletionSet(val historyItems: Set<PendingDeletionHistory>) : AppAction()
|
||||
/**
|
||||
* Replaces the list of available Pocket recommended stories categories.
|
||||
*/
|
||||
data class PocketStoriesCategoriesChange(val storiesCategories: List<PocketRecommendedStoriesCategory>) :
|
||||
AppAction()
|
||||
/**
|
||||
* Restores the list of Pocket recommended stories categories selections.
|
||||
*/
|
||||
data class PocketStoriesCategoriesSelectionsChange(
|
||||
val storiesCategories: List<PocketRecommendedStoriesCategory>,
|
||||
val categoriesSelected: List<PocketRecommendedStoriesSelectedCategory>
|
||||
|
|
|
@ -142,8 +142,11 @@ internal object AppStoreReducer {
|
|||
pocketStories = updatedCategoriesState.getFilteredStories()
|
||||
)
|
||||
}
|
||||
is AppAction.PocketStoriesChange -> state.copy(
|
||||
pocketStories = action.pocketStories
|
||||
is AppAction.PocketStoriesClean -> state.copy(
|
||||
pocketStoriesCategories = emptyList(),
|
||||
pocketStoriesCategoriesSelections = emptyList(),
|
||||
pocketStories = emptyList(),
|
||||
pocketSponsoredStories = emptyList()
|
||||
)
|
||||
is AppAction.PocketSponsoredStoriesChange -> state.copy(
|
||||
pocketSponsoredStories = action.sponsoredStories
|
||||
|
|
|
@ -237,7 +237,7 @@ class HomeFragment : Fragment() {
|
|||
)
|
||||
}
|
||||
} else {
|
||||
components.appStore.dispatch(AppAction.PocketStoriesChange(emptyList()))
|
||||
components.appStore.dispatch(AppAction.PocketStoriesClean)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ import mozilla.components.feature.tab.collections.TabCollection
|
|||
import mozilla.components.feature.top.sites.TopSite
|
||||
import mozilla.components.service.fxa.manager.FxaAccountManager
|
||||
import mozilla.components.service.pocket.PocketStory
|
||||
import mozilla.components.service.pocket.PocketStory.PocketRecommendedStory
|
||||
import mozilla.components.service.pocket.PocketStory.PocketSponsoredStory
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
|
@ -344,18 +343,23 @@ class AppStoreTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `Test updating the list of Pocket recommended stories`() = runTest {
|
||||
val story1 = PocketRecommendedStory("title1", "url", "imageUrl", "publisher", "category", 1, 1)
|
||||
val story2 = story1.copy("title2")
|
||||
appStore = AppStore(AppState())
|
||||
fun `Test cleaning the list of Pocket stories`() = runTest {
|
||||
appStore = AppStore(
|
||||
AppState(
|
||||
pocketStoriesCategories = listOf(mockk()),
|
||||
pocketStoriesCategoriesSelections = listOf(mockk()),
|
||||
pocketStories = listOf(mockk()),
|
||||
pocketSponsoredStories = listOf(mockk())
|
||||
)
|
||||
)
|
||||
|
||||
appStore.dispatch(AppAction.PocketStoriesChange(listOf(story1, story2)))
|
||||
appStore.dispatch(AppAction.PocketStoriesClean)
|
||||
.join()
|
||||
assertTrue(appStore.state.pocketStories.containsAll(listOf(story1, story2)))
|
||||
|
||||
val updatedStories = listOf(story2.copy("title3"))
|
||||
appStore.dispatch(AppAction.PocketStoriesChange(updatedStories)).join()
|
||||
assertTrue(updatedStories.containsAll(appStore.state.pocketStories))
|
||||
assertTrue(appStore.state.pocketStoriesCategories.isEmpty())
|
||||
assertTrue(appStore.state.pocketStoriesCategoriesSelections.isEmpty())
|
||||
assertTrue(appStore.state.pocketStories.isEmpty())
|
||||
assertTrue(appStore.state.pocketSponsoredStories.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -55,13 +55,8 @@
|
|||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$Change : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$CollectionExpanded : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$CollectionsChange : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$DeselectPocketStoriesCategory : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$DisbandSearchGroupAction : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$ModeChange : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$PocketStoriesCategoriesChange : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$PocketStoriesCategoriesSelectionsChange : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$PocketStoriesChange : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$PocketStoriesShown : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$RecentBookmarksChange : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$RecentHistoryChange : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$RecentTabsChange : AppAction</ID>
|
||||
|
@ -71,7 +66,6 @@
|
|||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$RemoveRecentBookmark : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$RemoveRecentHistoryHighlight : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$RemoveRecentTab : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$SelectPocketStoriesCategory : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$TopSitesChange : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppAction.kt$AppAction$UpdateInactiveExpanded : AppAction</ID>
|
||||
<ID>UndocumentedPublicClass:AppRequestInterceptor.kt$AppRequestInterceptor : RequestInterceptor</ID>
|
||||
|
|
Loading…
Reference in New Issue