refactor some usePlayerSong consumers to only fetch needed properties

This commit is contained in:
jeffvli
2026-01-21 02:02:49 -08:00
parent dbfb547af9
commit 9a4a8eb742
3 changed files with 266 additions and 211 deletions
+20
View File
@@ -1984,6 +1984,26 @@ export const usePlayerSong = () => {
);
};
export const usePlayerSongProperties = <T extends keyof QueueSong>(
properties: T[],
): Partial<Pick<QueueSong, T>> => {
return usePlayerStoreBase(
useShallow((state) => {
const song = state.getCurrentSong();
if (!song) {
return {};
}
const result = {} as Pick<QueueSong, T>;
for (const prop of properties) {
result[prop] = song[prop];
}
return result;
}),
);
};
export const usePlayerNum = () => {
return usePlayerStoreBase((state) => state.player.playerNum);
};