Persist lyrics queries in indexeddb

This commit is contained in:
jeffvli
2023-08-04 01:41:45 -07:00
parent adfa748bfb
commit ee83fdba71
6 changed files with 138 additions and 32 deletions
@@ -86,7 +86,7 @@ export const useSongLyricsBySong = (
const server = getServerById(song?.serverId);
return useQuery({
cacheTime: 1000 * 60 * 10,
cacheTime: Infinity,
enabled: !!song && !!server,
onError: () => {},
queryFn: async ({ signal }) => {
@@ -138,7 +138,7 @@ export const useSongLyricsBySong = (
return null;
},
queryKey: queryKeys.songs.lyrics(server?.id || '', query),
staleTime: 1000 * 60 * 2,
staleTime: Infinity,
});
};
@@ -146,7 +146,7 @@ export const SynchronizedLyrics = ({
'sychronized-lyrics-scroll-container',
) as HTMLElement;
const currentLyric = document.querySelector(`#lyric-${index}`) as HTMLElement;
const offsetTop = currentLyric?.offsetTop - doc?.clientHeight / 2 ?? 0;
const offsetTop = currentLyric.offsetTop - doc.clientHeight / 2 ?? 0;
if (currentLyric === null) {
lyricRef.current = undefined;