Fix override on song change

This commit is contained in:
jeffvli 2023-06-09 03:39:38 -07:00 committed by Jeff
parent 3d409bb6f1
commit aaa1b5f63a

View file

@ -106,6 +106,7 @@ export const Lyrics = () => {
const handleOnSearchOverride = useCallback((params: LyricsOverride) => {
setOverride(params);
setClear(false);
}, []);
const { data: overrideLyrics, isInitialLoading: isOverrideLoading } = useSongLyricsByRemoteId({
@ -120,9 +121,19 @@ export const Lyrics = () => {
});
useEffect(() => {
// We want to reset the clear flag whenever a song changes
setClear(false);
}, [currentSong]);
const unsubSongChange = usePlayerStore.subscribe(
(state) => state.current.song,
() => {
setOverride(undefined);
setClear(false);
},
{ equalityFn: (a, b) => a?.id === b?.id },
);
return () => {
unsubSongChange();
};
}, []);
const isLoadingLyrics = isInitialLoading || isOverrideLoading;