allow clear button to remove searched/override lyrics

This commit is contained in:
jeffvli
2025-12-04 01:38:38 -08:00
parent c14877916a
commit 376c09d1ea
+19 -2
View File
@@ -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;