Skip to content

Instantly share code, notes, and snippets.

@jubishop
Created October 14, 2025 21:46
Show Gist options
  • Select an option

  • Save jubishop/14753ab01018f481e7a43dcae11df3c8 to your computer and use it in GitHub Desktop.

Select an option

Save jubishop/14753ab01018f481e7a43dcae11df3c8 to your computer and use it in GitHub Desktop.
what a world.md

• Here’s the key sequence that can leave podcastList stale if we gate executeTrendingSectionFetch on trendingSection == currentTrendingSection:

  1. User taps a new chip. selectTrendingSection(:) updates currentTrendingSection, clears the list, triggers observeCurrentDisplay(), and kicks off performTrendingSectionFetch(: ).
  2. Before the fetch finishes, the user either jumps to a different trending chip or moves into search. At that instant the list already holds the “new” (possibly empty) dataset for what’s on screen.
  3. The original fetch eventually completes for the old section. If executeTrendingSectionFetch returns false (because the section no longer matches currentTrendingSection), the outer task skips observeCurrentDisplay(), so there’s no new syncPodcastListEntries() call.
  4. When the user returns to the chip whose data just landed, podcastList is still showing whatever collection was left from step 2—because we never updated it after the fetch completed—and it stays that way until Observatory emits a refresh for the same feed URLs (which may not happen immediately).

Keeping the unconditional true return lets the completion path always flow through observeCurrentDisplay(); that re-syncs podcastList.allEntries with the freshly fetched results, so the list is ready the moment the user navigates back. The extra observation re-subscription is idempotent, because the restart only wires up the currently visible surface (search or the active trending section) and ignores inactive sections.

› but in step two when the user jumps to a new trending chip or moves into search, a new call to observeCurrentDisplay() executes. so in step three when the original fetch completes, no call to observeCurrentDisplay is necessary anymore in step 3. then in step 4 when the user returns to the trending section originally selected in step 1, selectTrendingSection is called again and observeCurrentDisplay is called there too. so i still don't see why we needed a call to observeCurrentDisplay in step 3.

• Good catch—that sequence does stay safe because every navigation back into a section routes through selectTrendingSection, which calls observeCurrentDisplay() before the user ever sees the grid. We only need the completion path to force the resync when the finished fetch corresponds to whatever’s currently visible (the case where we actually want the UI to update right away).

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