mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 04:20:12 +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]);
|
||||
|
||||
const handleOnRemoveLyric = useCallback(() => {
|
||||
setOverride(undefined);
|
||||
|
||||
// Clear the main lyrics query cache
|
||||
queryClient.setQueryData(
|
||||
queryKeys.songs.lyrics(currentSong?._serverId, { songId: currentSong?.id }),
|
||||
(prev: FullLyricsMetadata | undefined) => {
|
||||
(prev: FullLyricsMetadata | StructuredLyric[] | undefined) => {
|
||||
if (!prev) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (Array.isArray(prev)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
...prev,
|
||||
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 () => {
|
||||
if (!lyrics) return;
|
||||
|
||||
Reference in New Issue
Block a user