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

Fix full screen player metadata may not change when switching queue #680

Merged
merged 1 commit into from
Jul 25, 2024

Conversation

dragonish
Copy link
Contributor

Issue

Referenced usePlayerData() hook in full-screen-player-image.tsx:

https://github.com/jeffvli/feishin/blob/0b786b025fdb376a19075a5ecf1864b6a6f5f18c/src/renderer/features/player/components/full-screen-player-image.tsx#L136C1-L138C39

const { queue } = usePlayerData();
const { useImageAspectRatio } = useFullScreenPlayerStore();
const currentSong = queue.current;

Then usePlayerData compares the equality dependent on PlayerData.current.nextIndex(value is nextSongIndex):

https://github.com/jeffvli/feishin/blob/0b786b025fdb376a19075a5ecf1864b6a6f5f18c/src/renderer/store/player.store.ts#L1053C1-L1059C7

export const usePlayerData = () =>
    usePlayerStore(
        (state) => state.actions.getPlayerData(),
        (a, b) => {
            return a.current.nextIndex === b.current.nextIndex;
        },
    );

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 always 1. This cause in the referenced usePlayerData() hook not changing. Its song information is still the first song in queue1.

For example, in the picture below:

bug

Solution

Use more reliable song information for equality comparison, such as: PlayerData.current.song?.uniqueId.

Copy link

vercel bot commented Jul 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
feishin ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 25, 2024 6:38pm

@jeffvli
Copy link
Owner

jeffvli commented Jul 25, 2024

Good catch, thanks!

@jeffvli jeffvli merged commit 4ca7b42 into jeffvli:development Jul 25, 2024
3 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