[tvOS] Episode/Season Focus gets Stuck (#1185)

* Focus on the first element if the lastFocusedEpisodeId isn't in the viewModel.

* Performance Improvements:
- Optimized Lookup:  Used a Set for efficient checking of whether lastFocusedEpisodeID exists in viewModel.elements.
- Single Pass:  Reduced the number of passes needed to check for existence and set the focusedEpisodeID.

* https://github.com/jellyfin/Swiftfin/pull/1185#pullrequestreview-2241625398 Suggestions

---------

Co-authored-by: Joseph Kribs <joseph@kribs.net>
This commit is contained in:
Joe 2024-08-16 12:30:15 -06:00 committed by GitHub
parent dcb3483e8d
commit 11c25648bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -85,6 +85,11 @@ extension SeriesEpisodeSelector {
guard let newValue else { return }
lastFocusedEpisodeID = newValue
}
.onChange(of: viewModel.state) { _, newValue in
if newValue == .content {
lastFocusedEpisodeID = viewModel.elements.first?.id
}
}
}
}