Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tvOS] Episode/Season Focus gets Stuck #1185

Merged
merged 4 commits into from
Aug 16, 2024

Conversation

JPKribs
Copy link
Contributor

@JPKribs JPKribs commented Aug 14, 2024

Issue

When entering a Show, focus can get trapped in the 'Seasons' HStack along the top. This can be reliably recreated by entering a Show, and changing the season prior to focusing on an episode. Because there is no 'LastFocusedEpisodeId', you are stuck until you are able to focus an Episode.

Resolution

This PR resolves this by adding a check to see if the LastFocusedEpisodeId exists in the current ViewModel. If the LastFocusedEpisodeId does not exist in the current ViewModel, it will always default to the first element in the current ViewModel.

If the LastFocusedEpisodeId does exists in the current ViewModel, it is used. This keeps the same functionality as before where moving between the episodes and seasons will always return you to the same episode you were on prior.

Focus Cursor Getting Stuck

Issue.mp4

Resolved

Resolved.mp4

Joseph Kribs added 2 commits August 14, 2024 11:16
- 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.
Copy link
Member

@LePips LePips left a comment

Choose a reason for hiding this comment

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

Hm so this issue is a bit more complex because this view isn't complete yet (by yours truly). For example, this view doesn't work correctly in the loading or error state.

We would have to play around with observing the viewModel.state and changing what should be focused when that changes. For example, the following fixes this immediate issue if you put this in the end of EpisodeHStack.body:

.onChange(of: viewModel.state) { _, newValue in
    if newValue == .content {
        lastFocusedEpisodeID = viewModel.elements.first?.id
    }
}

@JPKribs
Copy link
Contributor Author

JPKribs commented Aug 16, 2024

Good call! That resolves the issue I was seeing. I've changed this PR to only that change!

@JPKribs JPKribs requested a review from LePips August 16, 2024 03:12
@LePips LePips merged commit 11c2564 into jellyfin:main Aug 16, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants