Fix full screen player metadata may not change when switching queue #680
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Referenced
usePlayerData()
hook infull-screen-player-image.tsx
:https://github.com/jeffvli/feishin/blob/0b786b025fdb376a19075a5ecf1864b6a6f5f18c/src/renderer/features/player/components/full-screen-player-image.tsx#L136C1-L138C39
Then
usePlayerData
compares the equality dependent onPlayerData.current.nextIndex
(value isnextSongIndex
):https://github.com/jeffvli/feishin/blob/0b786b025fdb376a19075a5ecf1864b6a6f5f18c/src/renderer/store/player.store.ts#L1053C1-L1059C7
But this is not always reliable.
Assume the song has no track information, switch from the first song of queue1 to queue2, the value of
PlayerData.current.nextIndex
is always1
. This cause in the referencedusePlayerData()
hook not changing. Its song information is still the first song in queue1.For example, in the picture below:
Solution
Use more reliable song information for equality comparison, such as:
PlayerData.current.song?.uniqueId
.