Skip to content

Conversation

@kean
Copy link
Contributor

@kean kean commented Feb 4, 2026

Description

Fixes CMM-101: Stats: Posting Activity Shows No Data.

Note: the root cause is probably on part 3, but I decided to minimize the affected area and fixed the bug directly.

RCA

The Cache Reset Chain:

  1. User navigates to Insights screen
- `SiteStatsInsightsTableViewController.viewWillAppear` subscribes to `StatsInsightsStore`
- Store queries data and populates `state.postingActivity`
  1. User taps Posting Activity to view details
- Navigation pushes `PostingActivityViewController` onto the stack
- `SiteStatsInsightsTableViewController.viewWillDisappear` is called
- View controller unconditionally unsubscribes from the store
  1. Store detects no active queries and resets state
  // StatsInsightsStore.swift:229-236
  func processQueries() {
      guard !activeQueries.isEmpty else {
          // This being empty means a VC just unregistered from observing data.
          // Let's persist what we have a clear the in-memory store.
          saveDataInCache()
          state = InsightStoreState()  // ← All data cleared!
          return
      }
  }
  1. Detail screen finds empty store
    • PostingActivityViewController reads yearData from store
    • Store state was just reset, so postingActivity is nil
    • Collection view renders with 0 items

@kean kean force-pushed the fix/posting-activity-empty branch from 06f6b97 to 291b157 Compare February 4, 2026 15:35
@kean kean added the Stats label Feb 4, 2026
@kean kean added this to the 26.7 milestone Feb 4, 2026
@kean kean requested a review from crazytonyli February 4, 2026 15:35
@kean kean force-pushed the fix/posting-activity-empty branch from 291b157 to 6e18fba Compare February 4, 2026 15:37
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 4, 2026

@wpmobilebot
Copy link
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants