fredrikburmester / streamyfin

A Jellyfin client build with Expo
Mozilla Public License 2.0
1.12k stars 31 forks source link

Update visual playback when exiting video #181

Open Alexk2309 opened 1 month ago

Alexk2309 commented 1 month ago

This PR addresses an issue where the frontend UI was not updating instantly when a video stops playing. The changes ensure that the relevant queries are invalidated correctly, triggering an immediate UI update.

Note:

The new lines were just copied from the PlayedStatus.tsx file, this code could be refactored so that way both these two components could use one function. Please add a comment if you would like this.

Summary by Sourcery

Bug Fixes:

sourcery-ai[bot] commented 1 month ago

Reviewer's Guide by Sourcery

This pull request updates the stop function in the play-video.tsx file to invalidate multiple queries when video playback is stopped. This change ensures that the frontend UI updates immediately when a video stops playing, addressing an issue where the UI was not updating instantly.

Sequence diagram for video stop and UI update

sequenceDiagram
    actor User
    participant VideoPlayer as Video Player
    participant QueryClient as Query Client
    participant UI as User Interface

    User->>VideoPlayer: Stop video
    VideoPlayer->>QueryClient: Invalidate queries
    QueryClient->>UI: Trigger UI update
    UI->>User: Display updated UI

File-Level Changes

Change Details Files
Added query invalidation for multiple queries when stopping video playback
  • Imported useQueryClient hook from react-query
  • Added invalidation for 'item' query
  • Added invalidation for 'resumeItems' query
  • Added invalidation for 'continueWatching' query
  • Added invalidation for 'nextUp-all' query (duplicated)
  • Added invalidation for 'nextUp' query
  • Added invalidation for 'episodes' query
  • Added invalidation for 'seasons' query
  • Added invalidation for 'home' query
app/(auth)/play-video.tsx

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).
fredrikburmester commented 1 month ago

Could you please remove the duplicate 'nextUp-all' query and add the queryClient to the dep array and i'll merge this! Thank you!

Alexk2309 commented 1 month ago

@fredrikburmester Okay changes made!