Skip to content

Commit

Permalink
Merge pull request #21457 from wordpress-mobile/issue/21451-avg-view-…
Browse files Browse the repository at this point in the history
…more-link

Stats: remove avg "view more" link
  • Loading branch information
nbradbury authored Nov 13, 2024
2 parents 7553850 + ba6d8d6 commit fb219f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.wordpress.android.fluxc.store.StatsStore.PostDetailType
import org.wordpress.android.fluxc.store.stats.PostDetailStore
import org.wordpress.android.modules.BG_THREAD
import org.wordpress.android.modules.UI_THREAD
import org.wordpress.android.ui.stats.refresh.NavigationTarget.ViewDayAverageStats
import org.wordpress.android.ui.stats.refresh.lists.BLOCK_ITEM_COUNT
import org.wordpress.android.ui.stats.refresh.lists.VIEW_ALL_ITEM_COUNT
import org.wordpress.android.ui.stats.refresh.lists.detail.PostDetailMapper.ExpandedYearUiState
Expand All @@ -16,12 +15,10 @@ import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.Us
import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.UseCaseMode.VIEW_ALL
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Header
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Link
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Title
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.InsightUseCaseFactory
import org.wordpress.android.ui.stats.refresh.utils.StatsPostProvider
import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider
import org.wordpress.android.ui.utils.ListItemInteraction
import javax.inject.Inject
import javax.inject.Named

Expand Down Expand Up @@ -86,25 +83,24 @@ class PostAverageViewsPerDayUseCase(
)

items.addAll(yearList)
if (useCaseMode == BLOCK && domainModel.yearsAverage.size > itemsToLoad) {

// We don't currently have a detail view for this
// https://github.com/wordpress-mobile/WordPress-Android/issues/21458
/*if (useCaseMode == BLOCK && domainModel.yearsAverage.size > itemsToLoad) {
items.add(
Link(
text = R.string.stats_insights_view_more,
navigateAction = ListItemInteraction.create(this::onLinkClick)
navigateAction = ListItemInteraction.create(navigateTo(ViewDayAverageStats))
)
)
}
}*/
return items
}

private fun PostDetailStatsModel?.hasData(): Boolean {
return this != null && this.yearsAverage.isNotEmpty() && this.yearsAverage.any { it.value > 0 }
}

private fun onLinkClick() {
navigateTo(ViewDayAverageStats)
}

override fun buildLoadingItem(): List<BlockListItem> {
return listOf(Title(R.string.stats_detail_average_views_per_day))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.Us
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.ExpandableItem
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Header
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Link
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.ListItemWithIcon
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Title
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.EXPANDABLE_ITEM
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.HEADER
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.LINK
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.LIST_ITEM_WITH_ICON
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.TITLE
import org.wordpress.android.ui.stats.refresh.utils.StatsPostProvider
Expand Down Expand Up @@ -164,7 +162,8 @@ class PostAverageViewsPerDayUseCaseTest : BaseUnitTest() {
assertMonth(this[3], "Jan", month.count.toString())
}

@Test
// See https://github.com/wordpress-mobile/WordPress-Android/pull/21457
/*@Test
fun `adds view more button when hasMore`() = test {
val forced = false
val data = List(10) { year }
Expand Down Expand Up @@ -207,6 +206,12 @@ class PostAverageViewsPerDayUseCaseTest : BaseUnitTest() {
}
}
private fun assertLink(item: BlockListItem) {
assertThat(item.type).isEqualTo(LINK)
assertThat((item as Link).text).isEqualTo(R.string.stats_insights_view_more)
}
*/

@Test
fun `maps error item to UI model`() = test {
val forced = false
Expand Down Expand Up @@ -278,11 +283,6 @@ class PostAverageViewsPerDayUseCaseTest : BaseUnitTest() {
return item
}

private fun assertLink(item: BlockListItem) {
assertThat(item.type).isEqualTo(LINK)
assertThat((item as Link).text).isEqualTo(R.string.stats_insights_view_more)
}

private suspend fun loadData(refresh: Boolean, forced: Boolean): UseCaseModel {
var result: UseCaseModel? = null
useCase.liveData.observeForever { result = it }
Expand Down

0 comments on commit fb219f1

Please sign in to comment.