Fix override on song change
This commit is contained in:
parent
3d409bb6f1
commit
aaa1b5f63a
1 changed files with 14 additions and 3 deletions
|
@ -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;
|
||||
|
||||
|
|
Reference in a new issue