mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 02:13:33 +00:00
Add lyric search functions and query
This commit is contained in:
parent
43c11ab6e3
commit
0fa5b6496f
7 changed files with 210 additions and 23 deletions
20
src/renderer/features/lyrics/queries/lyric-search-query.ts
Normal file
20
src/renderer/features/lyrics/queries/lyric-search-query.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { useQuery } from '@tanstack/react-query';
|
||||
import isElectron from 'is-electron';
|
||||
import { queryKeys } from '/@/renderer/api/query-keys';
|
||||
import { InternetProviderLyricSearchResponse, LyricSearchQuery } from '/@/renderer/api/types';
|
||||
import { QueryHookArgs } from '/@/renderer/lib/react-query';
|
||||
import { LyricSource } from '/@/renderer/types';
|
||||
|
||||
const lyricsIpc = isElectron() ? window.electron.lyrics : null;
|
||||
|
||||
export const useLyricSearch = (args: Omit<QueryHookArgs<LyricSearchQuery>, 'serverId'>) => {
|
||||
const { options, query } = args;
|
||||
|
||||
return useQuery<Record<LyricSource, InternetProviderLyricSearchResponse[]>>({
|
||||
cacheTime: 1000 * 60 * 1,
|
||||
queryFn: () => lyricsIpc?.searchRemoteLyrics(query),
|
||||
queryKey: queryKeys.songs.lyricsSearch(query),
|
||||
staleTime: 1000 * 60 * 1,
|
||||
...options,
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue