CMM-1952: Skip data fetching for hidden Insights cards and polish detail screens#22688
CMM-1952: Skip data fetching for hidden Insights cards and polish detail screens#22688adalpari wants to merge 11 commits intofeat/CMM-1936-create-insights-tabfrom
Conversation
…c field The detail screen now has its own ViewModel that fetches up to 100 items directly from the API, while the card continues to fetch 10. This removes the static data holder pattern that was prone to data loss on process death. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…all 10 card items - Extract TagsAndCategoriesMapper to deduplicate TagGroupData to TagGroupUiItem mapping between card and detail ViewModels - Add unit tests for TagsAndCategoriesDetailViewModel - Add isLoaded/isLoading guards to detail VM to prevent double fetches - Remove CARD_MAX_ITEMS limit so card displays all 10 fetched items - Remove unused import in DetailActivity Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Only call summary/insights endpoints when visible cards need them, avoiding unnecessary network calls for hidden cards. Track which endpoint groups have been fetched so re-adding a hidden card triggers a fetch for its missing data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prevents setting isDataLoaded=true when no cards require fetching, which would block future fetches when cards are re-added to the visible list. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace duplicate shimmer animation in YearInReviewCard with shared rememberShimmerBrush() utility - Extract StatsTagsUseCase to centralize token validation and repository init, removing duplication between Tags ViewModels - Add card reordering tests for middle elements in InsightsCardsConfigurationRepositoryTest - Fix locale-dependent assertions in MostPopularDayViewModelTest Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Generated by 🚫 Danger |
|
Claude finished @adalpari's task in 2m 56s —— View job Code Review
Overall this is a well-structured PR. The architecture is clean, the conditional fetching logic is a nice optimization, and test coverage is solid. I found a few issues worth addressing before merging. Bugs1. Process-death / back-stack restore leaves detail screen stuck in Loading
if (savedInstanceState == null) {
viewModel.loadData()
}This guard is correct for configuration changes (rotation), but after a system-initiated process death and restore, the activity is recreated with a non-null 2.
3. Tags card is excluded from
Code Quality4.
@Volatile private var isDataLoaded = false
@Volatile private var isDataLoading = falseThe check-then-act in if (isDataLoaded || isDataLoading) return // read
isDataLoading = true // write
5. Raw exception messages exposed to users
} catch (e: Exception) {
_uiState.value = TagsAndCategoriesCardUiState.Error(
e.message ?: resourceProvider.getString(R.string.stats_error_unknown)
)
6. Significant code duplication between the two Tags ViewModels
Testing Gaps7. Missing test: only
8. No test for When Minor
|
Project dependencies changeslist! Upgraded Dependencies
rs.wordpress.api:android:1230-d4c9317af369c7231b414998986fd2e773eebf7d, (changed from trunk-4fac42b1a262e93adcbc0cd0353aafa0369671d2)
rs.wordpress.api:kotlin:1230-d4c9317af369c7231b414998986fd2e773eebf7d, (changed from trunk-4fac42b1a262e93adcbc0cd0353aafa0369671d2)tree +--- project :libs:fluxc
-| \--- rs.wordpress.api:android:trunk-4fac42b1a262e93adcbc0cd0353aafa0369671d2
-| +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
-| +--- com.squareup.okhttp3:okhttp-tls:5.3.2
-| | +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
-| | +--- com.squareup.okio:okio:3.16.4 (*)
-| | \--- org.jetbrains.kotlin:kotlin-stdlib:2.2.21 -> 2.3.10 (*)
-| +--- net.java.dev.jna:jna:5.18.1
-| +--- rs.wordpress.api:kotlin:trunk-4fac42b1a262e93adcbc0cd0353aafa0369671d2
-| | +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
-| | +--- com.squareup.okhttp3:okhttp-tls:5.3.2 (*)
-| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2 (*)
-| | \--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.3.10 (*)
-| \--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.3.10 (*)
+| \--- rs.wordpress.api:android:1230-d4c9317af369c7231b414998986fd2e773eebf7d
+| +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
+| +--- com.squareup.okhttp3:okhttp-tls:5.3.2
+| | +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
+| | +--- com.squareup.okio:okio:3.16.4 (*)
+| | \--- org.jetbrains.kotlin:kotlin-stdlib:2.2.21 -> 2.3.10 (*)
+| +--- net.java.dev.jna:jna:5.18.1
+| +--- rs.wordpress.api:kotlin:1230-d4c9317af369c7231b414998986fd2e773eebf7d
+| | +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
+| | +--- com.squareup.okhttp3:okhttp-tls:5.3.2 (*)
+| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2 (*)
+| | \--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.3.10 (*)
+| \--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.3.10 (*)
-\--- rs.wordpress.api:android:trunk-4fac42b1a262e93adcbc0cd0353aafa0369671d2 (*)
+\--- rs.wordpress.api:android:1230-d4c9317af369c7231b414998986fd2e773eebf7d (*) |
- Call loadData() unconditionally in TagsAndCategoriesDetailActivity onCreate to handle process-death restore (loadData guard prevents double fetch on rotation) - Add Mutex-protected in-memory cache to StatsTagsUseCase, consistent with StatsSummaryUseCase and StatsInsightsUseCase - Pass forceRefresh=true on pull-to-refresh in TagsAndCategoriesViewModel Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
|
|
Use AtomicBoolean with compareAndSet in InsightsViewModel to prevent race conditions, rethrow CancellationException in base tags ViewModel, and only mark endpoints as fetched on success results. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|





Description
Improves the Insights tab by skipping unnecessary network calls for hidden cards and polishing the Tags & Categories detail screen.
Changes:
InsightsViewModel.fetchData()now only calls summary/insights endpoints when visible cards need them, avoiding wasted network calls for hidden cardssummaryFetched/insightsFetched) so re-adding a hidden card triggers a fetch for its missing dataTagsAndCategoriesMapper, addsTagsAndCategoriesDetailViewModelTest, guards against double fetch calls, shows all 10 card itemsYearInReviewCardwith sharedrememberShimmerBrush()MostPopularDayViewModelTestmoveCardUp/moveCardDown/moveCardToTop/moveCardToBottomon middle elementsTesting instructions
Conditional fetching:
Tags & Categories detail screen:
Card reordering: