Skip to content

Commit 81d0c74

Browse files
authored
Merge pull request #10078 from wordpress-mobile/feature/remove_comments_view_more
Remove Comments view all screen
2 parents 078154a + 399dfb2 commit 81d0c74

File tree

6 files changed

+8
-140
lines changed

6 files changed

+8
-140
lines changed

WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsModule.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import org.wordpress.android.ui.stats.refresh.lists.sections.granular.usecases.S
3535
import org.wordpress.android.ui.stats.refresh.lists.sections.granular.usecases.VideoPlaysUseCase.VideoPlaysUseCaseFactory
3636
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.usecases.AllTimeStatsUseCase
3737
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.usecases.AnnualSiteStatsUseCase.AnnualSiteStatsUseCaseFactory
38-
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.usecases.CommentsUseCase.CommentsUseCaseFactory
38+
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.usecases.CommentsUseCase
3939
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.usecases.FollowerTotalsUseCase
4040
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.usecases.FollowersUseCase.FollowersUseCaseFactory
4141
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.usecases.LatestPostSummaryUseCase
@@ -81,7 +81,7 @@ class StatsModule {
8181
latestPostSummaryUseCase: LatestPostSummaryUseCase,
8282
todayStatsUseCase: TodayStatsUseCase,
8383
followersUseCaseFactory: FollowersUseCaseFactory,
84-
commentsUseCaseFactory: CommentsUseCaseFactory,
84+
commentsUseCase: CommentsUseCase,
8585
mostPopularInsightsUseCase: MostPopularInsightsUseCase,
8686
tagsAndCategoriesUseCaseFactory: TagsAndCategoriesUseCaseFactory,
8787
publicizeUseCaseFactory: PublicizeUseCaseFactory,
@@ -96,7 +96,7 @@ class StatsModule {
9696
latestPostSummaryUseCase,
9797
todayStatsUseCase,
9898
followersUseCaseFactory.build(BLOCK),
99-
commentsUseCaseFactory.build(BLOCK),
99+
commentsUseCase,
100100
mostPopularInsightsUseCase,
101101
tagsAndCategoriesUseCaseFactory.build(BLOCK),
102102
publicizeUseCaseFactory.build(BLOCK),
@@ -117,7 +117,6 @@ class StatsModule {
117117
@Named(VIEW_ALL_INSIGHTS_USE_CASES)
118118
fun provideViewAllInsightsUseCases(
119119
followersUseCaseFactory: FollowersUseCaseFactory,
120-
commentsUseCaseFactory: CommentsUseCaseFactory,
121120
tagsAndCategoriesUseCaseFactory: TagsAndCategoriesUseCaseFactory,
122121
publicizeUseCaseFactory: PublicizeUseCaseFactory,
123122
postMonthsAndYearsUseCaseFactory: PostMonthsAndYearsUseCaseFactory,
@@ -127,7 +126,6 @@ class StatsModule {
127126
): List<@JvmSuppressWildcards BaseStatsUseCase<*, *>> {
128127
return listOf(
129128
followersUseCaseFactory.build(VIEW_ALL),
130-
commentsUseCaseFactory.build(VIEW_ALL),
131129
tagsAndCategoriesUseCaseFactory.build(VIEW_ALL),
132130
publicizeUseCaseFactory.build(VIEW_ALL),
133131
postMonthsAndYearsUseCaseFactory.build(VIEW_ALL),

WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewAllViewModelFactory.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import org.wordpress.android.ui.stats.StatsViewType
1212
import org.wordpress.android.ui.stats.StatsViewType.ANNUAL_STATS
1313
import org.wordpress.android.ui.stats.StatsViewType.AUTHORS
1414
import org.wordpress.android.ui.stats.StatsViewType.CLICKS
15-
import org.wordpress.android.ui.stats.StatsViewType.COMMENTS
1615
import org.wordpress.android.ui.stats.StatsViewType.DETAIL_AVERAGE_VIEWS_PER_DAY
1716
import org.wordpress.android.ui.stats.StatsViewType.DETAIL_MONTHS_AND_YEARS
1817
import org.wordpress.android.ui.stats.StatsViewType.DETAIL_RECENT_WEEKS
@@ -45,7 +44,6 @@ import org.wordpress.android.ui.stats.refresh.lists.sections.granular.usecases.S
4544
import org.wordpress.android.ui.stats.refresh.lists.sections.granular.usecases.VideoPlaysUseCase.VideoPlaysUseCaseFactory
4645
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.usecases.AllTimeStatsUseCase
4746
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.usecases.AnnualSiteStatsUseCase
48-
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.usecases.CommentsUseCase
4947
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.usecases.FollowersUseCase
5048
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.usecases.LatestPostSummaryUseCase
5149
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.usecases.MostPopularInsightsUseCase
@@ -172,10 +170,6 @@ class StatsViewAllViewModelFactory(
172170
insightsUseCases.first { it is FollowersUseCase },
173171
R.string.stats_view_followers
174172
)
175-
COMMENTS -> Pair(
176-
insightsUseCases.first { it is CommentsUseCase },
177-
R.string.stats_view_comments
178-
)
179173
TAGS_AND_CATEGORIES -> Pair(
180174
insightsUseCases.first { it is TagsAndCategoriesUseCase },
181175
R.string.stats_view_tags_and_categories

WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/usecases/CommentsUseCase.kt

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,23 @@ package org.wordpress.android.ui.stats.refresh.lists.sections.insights.usecases
33
import android.view.View
44
import kotlinx.coroutines.CoroutineDispatcher
55
import org.wordpress.android.R
6-
import org.wordpress.android.analytics.AnalyticsTracker
76
import org.wordpress.android.fluxc.model.stats.CommentsModel
87
import org.wordpress.android.fluxc.model.stats.LimitMode
98
import org.wordpress.android.fluxc.store.StatsStore.InsightType.COMMENTS
109
import org.wordpress.android.fluxc.store.stats.insights.CommentsStore
1110
import org.wordpress.android.modules.UI_THREAD
12-
import org.wordpress.android.ui.stats.refresh.NavigationTarget.ViewCommentsStats
1311
import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.StatefulUseCase
14-
import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.UseCaseMode.BLOCK
15-
import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.UseCaseMode.VIEW_ALL
1612
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem
1713
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Empty
1814
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Header
19-
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Link
2015
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.ListItem
2116
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.ListItemWithIcon
2217
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.ListItemWithIcon.IconStyle.AVATAR
23-
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.NavigationAction
2418
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.TabsItem
2519
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Title
26-
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.InsightUseCaseFactory
2720
import org.wordpress.android.ui.stats.refresh.utils.ItemPopupMenuHandler
2821
import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider
2922
import org.wordpress.android.ui.stats.refresh.utils.toFormattedString
30-
import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper
3123
import javax.inject.Inject
3224
import javax.inject.Named
3325

@@ -40,12 +32,10 @@ class CommentsUseCase
4032
@Named(UI_THREAD) private val mainDispatcher: CoroutineDispatcher,
4133
private val commentsStore: CommentsStore,
4234
private val statsSiteProvider: StatsSiteProvider,
43-
private val analyticsTracker: AnalyticsTrackerWrapper,
44-
private val popupMenuHandler: ItemPopupMenuHandler,
45-
private val useCaseMode: UseCaseMode
35+
private val popupMenuHandler: ItemPopupMenuHandler
4636
) : StatefulUseCase<CommentsModel, SelectedTabUiState>(COMMENTS, mainDispatcher, 0) {
4737
override suspend fun fetchRemoteData(forced: Boolean): State<CommentsModel> {
48-
val fetchMode = if (useCaseMode == VIEW_ALL) LimitMode.All else LimitMode.Top(BLOCK_ITEM_COUNT)
38+
val fetchMode = LimitMode.Top(BLOCK_ITEM_COUNT)
4939
val response = commentsStore.fetchComments(statsSiteProvider.siteModel, fetchMode, forced)
5040
val model = response.model
5141
val error = response.error
@@ -61,7 +51,7 @@ class CommentsUseCase
6151
}
6252

6353
override suspend fun loadCachedData(): CommentsModel? {
64-
val cacheMode = if (useCaseMode == VIEW_ALL) LimitMode.All else LimitMode.Top(BLOCK_ITEM_COUNT)
54+
val cacheMode = LimitMode.Top(BLOCK_ITEM_COUNT)
6555
return commentsStore.getComments(statsSiteProvider.siteModel, cacheMode)
6656
}
6757

@@ -73,11 +63,7 @@ class CommentsUseCase
7363

7464
override fun buildStatefulUiModel(model: CommentsModel, uiState: Int): List<BlockListItem> {
7565
val items = mutableListOf<BlockListItem>()
76-
77-
if (useCaseMode == BLOCK) {
78-
items.add(buildTitle())
79-
}
80-
66+
items.add(buildTitle())
8167
if (model.authors.isNotEmpty() || model.posts.isNotEmpty()) {
8268
items.add(
8369
TabsItem(
@@ -91,15 +77,6 @@ class CommentsUseCase
9177
} else {
9278
items.addAll(buildPostsTab(model.posts))
9379
}
94-
95-
if (model.hasMoreAuthors && uiState == 0 || model.hasMorePosts && uiState == 1) {
96-
items.add(
97-
Link(
98-
text = R.string.stats_insights_view_more,
99-
navigateAction = NavigationAction.create(uiState, this::onLinkClick)
100-
)
101-
)
102-
}
10380
} else {
10481
items.add(Empty())
10582
}
@@ -144,31 +121,7 @@ class CommentsUseCase
144121
return mutableItems
145122
}
146123

147-
private fun onLinkClick(selectedTab: Int) {
148-
analyticsTracker.track(AnalyticsTracker.Stat.STATS_COMMENTS_VIEW_MORE_TAPPED)
149-
navigateTo(ViewCommentsStats(selectedTab))
150-
}
151-
152124
private fun onMenuClick(view: View) {
153125
popupMenuHandler.onMenuClick(view, type)
154126
}
155-
156-
class CommentsUseCaseFactory
157-
@Inject constructor(
158-
@Named(UI_THREAD) private val mainDispatcher: CoroutineDispatcher,
159-
private val commentsStore: CommentsStore,
160-
private val statsSiteProvider: StatsSiteProvider,
161-
private val analyticsTracker: AnalyticsTrackerWrapper,
162-
private val popupMenuHandler: ItemPopupMenuHandler
163-
) : InsightUseCaseFactory {
164-
override fun build(useCaseMode: UseCaseMode) =
165-
CommentsUseCase(
166-
mainDispatcher,
167-
commentsStore,
168-
statsSiteProvider,
169-
analyticsTracker,
170-
popupMenuHandler,
171-
useCaseMode
172-
)
173-
}
174127
}

WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/usecases/CommentsUseCaseTest.kt

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ import org.wordpress.android.fluxc.store.StatsStore.StatsError
2020
import org.wordpress.android.fluxc.store.StatsStore.StatsErrorType.GENERIC_ERROR
2121
import org.wordpress.android.fluxc.store.stats.insights.CommentsStore
2222
import org.wordpress.android.test
23-
import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.UseCaseMode.BLOCK
2423
import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.UseCaseModel
2524
import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.UseCaseModel.UseCaseState
2625
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem
2726
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Empty
2827
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Header
29-
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Link
3028
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.ListItem
3129
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.ListItemWithIcon
3230
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.ListItemWithIcon.IconStyle.AVATAR
@@ -60,9 +58,7 @@ class CommentsUseCaseTest : BaseUnitTest() {
6058
Dispatchers.Unconfined,
6159
insightsStore,
6260
statsSiteProvider,
63-
tracker,
64-
popupMenuHandler,
65-
BLOCK
61+
popupMenuHandler
6662
)
6763
whenever(statsSiteProvider.siteModel).thenReturn(site)
6864
}
@@ -96,70 +92,6 @@ class CommentsUseCaseTest : BaseUnitTest() {
9692
updatedResult.data!!.assertTabWithPosts(1)
9793
}
9894

99-
@Test
100-
fun `adds link to UI model when has more posts`() = test {
101-
val forced = false
102-
val model = CommentsModel(
103-
listOf(Post(postId, postTitle, totalCount, url)),
104-
listOf(),
105-
hasMorePosts = true,
106-
hasMoreAuthors = false
107-
)
108-
whenever(insightsStore.getComments(eq(statsSiteProvider.siteModel), any())).thenReturn(model)
109-
whenever(insightsStore.fetchComments(site, LimitMode.Top(blockItemCount), forced)).thenReturn(
110-
OnStatsFetched(
111-
model
112-
)
113-
)
114-
115-
val result = loadComments(true, forced)
116-
117-
assertThat(result.type).isEqualTo(InsightType.COMMENTS)
118-
assertThat(result.state).isEqualTo(UseCaseState.SUCCESS)
119-
result.data!!.apply {
120-
assertThat(this).hasSize(3)
121-
assertThat(this[1] is TabsItem).isTrue()
122-
assertTitle(this[0])
123-
assertThat(this[2] is Link).isFalse()
124-
}
125-
126-
(result.data!![1] as TabsItem).onTabSelected(1)
127-
val updatedResult = loadComments(true, forced)
128-
129-
updatedResult.data!!.apply {
130-
assertThat(this).hasSize(5)
131-
assertTitle(this[0])
132-
assertThat(this[4] is Link).isTrue()
133-
}
134-
}
135-
136-
@Test
137-
fun `adds link to UI model when has more authors`() = test {
138-
val forced = false
139-
val model = CommentsModel(
140-
listOf(Post(postId, postTitle, totalCount, url)),
141-
listOf(),
142-
hasMorePosts = false,
143-
hasMoreAuthors = true
144-
)
145-
whenever(insightsStore.getComments(eq(statsSiteProvider.siteModel), any())).thenReturn(model)
146-
whenever(insightsStore.fetchComments(site, LimitMode.Top(blockItemCount), forced)).thenReturn(
147-
OnStatsFetched(
148-
model
149-
)
150-
)
151-
152-
val result = loadComments(true, forced)
153-
154-
assertThat(result.type).isEqualTo(InsightType.COMMENTS)
155-
assertThat(result.state).isEqualTo(UseCaseState.SUCCESS)
156-
result.data!!.apply {
157-
assertThat(this).hasSize(4)
158-
assertTitle(this[0])
159-
assertThat(this[3] is Link).isTrue()
160-
}
161-
}
162-
16395
@Test
16496
fun `maps comment authors to UI model`() = test {
16597
val forced = false
@@ -281,12 +213,6 @@ class CommentsUseCaseTest : BaseUnitTest() {
281213
return tabsItem
282214
}
283215

284-
private fun List<BlockListItem>.assertEmpty() {
285-
assertThat(this).hasSize(2)
286-
assertTitle(this[0])
287-
assertThat(this[1]).isEqualTo(Empty())
288-
}
289-
290216
private fun assertTitle(item: BlockListItem) {
291217
assertThat(item.type).isEqualTo(TITLE)
292218
assertThat((item as Title).textResource).isEqualTo(R.string.stats_view_comments)

libs/analytics/WordPressAnalytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ public enum Stat {
9595
STATS_PERIOD_YEARS_ACCESSED,
9696
STATS_VIEW_ALL_ACCESSED,
9797
STATS_FOLLOWERS_VIEW_MORE_TAPPED,
98-
STATS_COMMENTS_VIEW_MORE_TAPPED,
9998
STATS_TAGS_AND_CATEGORIES_VIEW_MORE_TAPPED,
10099
STATS_PUBLICIZE_VIEW_MORE_TAPPED,
101100
STATS_POSTS_AND_PAGES_VIEW_MORE_TAPPED,

libs/analytics/WordPressAnalytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,8 +1011,6 @@ public static String getEventNameForStat(AnalyticsTracker.Stat stat) {
10111011
return "stats_view_all_accessed";
10121012
case STATS_FOLLOWERS_VIEW_MORE_TAPPED:
10131013
return "stats_followers_view_more_tapped";
1014-
case STATS_COMMENTS_VIEW_MORE_TAPPED:
1015-
return "stats_comments_view_more_tapped";
10161014
case STATS_TAGS_AND_CATEGORIES_VIEW_MORE_TAPPED:
10171015
return "stats_tags_and_categories_view_more_tapped";
10181016
case STATS_PUBLICIZE_VIEW_MORE_TAPPED:

0 commit comments

Comments
 (0)