mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
allow clear button to remove searched/override lyrics
This commit is contained in:
@@ -178,20 +178,37 @@ export const Lyrics = () => {
|
|||||||
// }, [currentSong?.id, currentSong?._serverId]);
|
// }, [currentSong?.id, currentSong?._serverId]);
|
||||||
|
|
||||||
const handleOnRemoveLyric = useCallback(() => {
|
const handleOnRemoveLyric = useCallback(() => {
|
||||||
|
setOverride(undefined);
|
||||||
|
|
||||||
|
// Clear the main lyrics query cache
|
||||||
queryClient.setQueryData(
|
queryClient.setQueryData(
|
||||||
queryKeys.songs.lyrics(currentSong?._serverId, { songId: currentSong?.id }),
|
queryKeys.songs.lyrics(currentSong?._serverId, { songId: currentSong?.id }),
|
||||||
(prev: FullLyricsMetadata | undefined) => {
|
(prev: FullLyricsMetadata | StructuredLyric[] | undefined) => {
|
||||||
if (!prev) {
|
if (!prev) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(prev)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...prev,
|
...prev,
|
||||||
lyrics: '',
|
lyrics: '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}, [currentSong?.id, currentSong?._serverId]);
|
|
||||||
|
// Clear the override query cache if it exists
|
||||||
|
if (override) {
|
||||||
|
queryClient.removeQueries({
|
||||||
|
queryKey: queryKeys.songs.lyricsByRemoteId({
|
||||||
|
remoteSongId: override.id,
|
||||||
|
remoteSource: override.source,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [currentSong?.id, currentSong?._serverId, override]);
|
||||||
|
|
||||||
const fetchTranslation = useCallback(async () => {
|
const fetchTranslation = useCallback(async () => {
|
||||||
if (!lyrics) return;
|
if (!lyrics) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user