rename some files and add nip 94 widget
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { invoke } from '@tauri-apps/api/tauri';
|
||||
|
||||
import { Opengraph } from '@utils/types';
|
||||
|
||||
export function useOpenGraph(url: string) {
|
||||
const { status, data, error } = useQuery(
|
||||
['preview', url],
|
||||
async () => {
|
||||
const res: Opengraph = await invoke('opengraph', { url });
|
||||
if (!res) {
|
||||
throw new Error('fetch preview failed');
|
||||
}
|
||||
return res;
|
||||
},
|
||||
{
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnMount: false,
|
||||
refetchOnReconnect: false,
|
||||
staleTime: Infinity,
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
status,
|
||||
data,
|
||||
error,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user