Skip to content

TV: Cache main tab models and extract scroll-offset modifier#4572

Open
SergioEstevao wants to merge 13 commits into
trunkfrom
sergio/pc-tv/cache_main_models
Open

TV: Cache main tab models and extract scroll-offset modifier#4572
SergioEstevao wants to merge 13 commits into
trunkfrom
sergio/pc-tv/cache_main_models

Conversation

@SergioEstevao

@SergioEstevao SergioEstevao commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes: PCIOS-753

Performance and structural cleanup for the Pocket Casts TV App main tab UI.

The tab content models (Home, My Podcasts, Playlists, Up Next, Search, Discover All) were previously recreated on each tab presentation. This PR hoists them onto MainTabViewModel so they are constructed once and cached for the lifetime of the tab router, avoiding redundant reloads when switching tabs.

It also tidies up the tab content view:

  • Cached models — Up Next, Playlists, Search, and Discover All models now live on the main tab view model and are reused across tab switches.
  • trackScrollOffset modifier — the four (now five) identical .onScrollGeometryChange blocks in MainTabContentView are extracted into a single reusable trackScrollOffset() view modifier that reports the scroll offset to the view model.
  • Animation fix — removed a .if and a ZStack wrapper that were interfering with tab transition animations.
  • Removed unused code and ran the linter.

To test

  1. Launch the Pocket Casts TV app.
  2. Navigate between the Home, Podcasts, Playlists, Up Next, and Search tabs.
  3. Confirm each tab loads correctly and the profile/logo accessory still parallax-scrolls with content (driven by the scroll offset).
  4. Confirm tab switching animates smoothly with no flicker.

Checklist

  • I have considered if this change warrants user-facing release notes and have added them to CHANGELOG.md if necessary.
  • I have considered adding unit tests for my changes.
  • I have updated (or requested that someone edit) the Event Horizon schema to reflect any new or changed analytics.

@dangermattic

dangermattic commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator
1 Warning
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.

Generated by 🚫 Danger

@SergioEstevao SergioEstevao added this to the Future milestone Jun 19, 2026
@SergioEstevao SergioEstevao marked this pull request as ready for review June 19, 2026 11:23
@SergioEstevao SergioEstevao requested a review from a team as a code owner June 19, 2026 11:23
@SergioEstevao SergioEstevao requested review from Copilot and kean and removed request for a team June 19, 2026 11:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves performance and structure in the Pocket Casts TV App main tab UI by caching tab-scoped view models in MainTabViewModel (so tabs don’t rebuild their models on each presentation) and extracting the repeated scroll-offset tracking logic into a reusable modifier.

Changes:

  • Hoist and cache Home/Podcasts/Playlists/Up Next/Search/Discover All view models onto MainTabViewModel and inject them into tab views.
  • Extract repeated .onScrollGeometryChange logic into a trackScrollOffset() modifier and apply it across tab content.
  • Remove SearchViewContainer, tweak layout in RootView, and adjust tab transition structure.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Pocket Casts TV App/UI/UpNext/UpNextView.swift Accepts an injected UpNextViewModel and updates environment dependency to MainTabViewModel.
Pocket Casts TV App/UI/Starred/StarredEpisodesView.swift Updates preview environment injection to MainTabViewModel.
Pocket Casts TV App/UI/Search/SearchViewContainer.swift Removes the container wrapper now that SearchViewModel is injected/cached elsewhere.
Pocket Casts TV App/UI/Search/SearchResultsView.swift Switches environment dependency to MainTabViewModel and reuses cached DiscoverAllViewModel.
Pocket Casts TV App/UI/RootView.swift Adjusts loading layout sizing (frame(maxWidth: .infinity)).
Pocket Casts TV App/UI/Podcasts/PodcastsView.swift Updates environment dependency to MainTabViewModel and preview injection.
Pocket Casts TV App/UI/Podcasts/PodcastDetailView.swift Renames router environment dependency to MainTabViewModel and updates preview.
Pocket Casts TV App/UI/Podcasts/EpisodeRow.swift Updates preview environment injection to MainTabViewModel.
Pocket Casts TV App/UI/Playlists/PlaylistsView.swift Accepts an injected PlaylistsViewModel and updates environment dependency to MainTabViewModel.
Pocket Casts TV App/UI/Playlists/PlaylistDetailView.swift Renames router environment dependency to MainTabViewModel and updates preview.
Pocket Casts TV App/UI/Playlists/PlaylistCell.swift Updates preview environment injection to MainTabViewModel.
Pocket Casts TV App/UI/Player/NowPlayingTab.swift Updates environment dependency to MainTabViewModel.
Pocket Casts TV App/UI/Player/NowPlayingRow.swift Updates preview environment injection to MainTabViewModel.
Pocket Casts TV App/UI/MainTabViewModel.swift Renames router to MainTabViewModel and adds cached tab view models.
Pocket Casts TV App/UI/MainTabView.swift Uses cached models, adds trackScrollOffset() modifier, and removes wrapper impacting animations.
Pocket Casts TV App/UI/Home/HomeView.swift Accepts an injected HomeViewModel and updates environment dependency to MainTabViewModel.
Pocket Casts TV App/UI/History/ListeningHistoryView.swift Updates preview environment injection to MainTabViewModel.
Pocket Casts TV App/UI/Discover/DiscoverVideoEpisodeCell.swift Updates preview environment injection to MainTabViewModel.
Pocket Casts TV App/UI/Discover/DiscoverPodcastsListView.swift Renames router environment dependency to MainTabViewModel and updates preview.
Pocket Casts TV App/UI/Discover/DiscoverFeaturedPodcastCell.swift Updates preview environment injection to MainTabViewModel.
Pocket Casts TV App/UI/Discover/DiscoverCategoryCell.swift Updates preview environment injection to MainTabViewModel.
Pocket Casts TV App/UI/Discover/DiscoverAllView.swift Accepts an injected DiscoverAllViewModel and removes direct scroll-offset reporting.

Comment thread Pocket Casts TV App/UI/MainTabView.swift
Comment thread Pocket Casts TV App/UI/MainTabView.swift Outdated
Comment thread Pocket Casts TV App/UI/Discover/DiscoverAllView.swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants