WIP
This commit is contained in:
@@ -2,10 +2,16 @@ import { getActiveAccount } from "@libs/storage";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
export function useAccount() {
|
||||
const { status, data: account } = useQuery(["currentAccount"], async () => {
|
||||
const res = await getActiveAccount();
|
||||
return res;
|
||||
});
|
||||
const { status, data: account } = useQuery(
|
||||
["currentAccount"],
|
||||
async () => await getActiveAccount(),
|
||||
{
|
||||
staleTime: Infinity,
|
||||
refetchOnMount: true,
|
||||
refetchOnWindowFocus: false,
|
||||
refetchOnReconnect: true,
|
||||
},
|
||||
);
|
||||
|
||||
return { status, account };
|
||||
}
|
||||
|
||||
@@ -5,7 +5,11 @@ export function useOpenGraph(url: string) {
|
||||
const { status, data, error, isFetching } = useQuery(
|
||||
["preview", url],
|
||||
async () => {
|
||||
return await getLinkPreview(url);
|
||||
const res = await getLinkPreview(url);
|
||||
if (!res) {
|
||||
throw new Error("Can' fetch");
|
||||
}
|
||||
return res;
|
||||
},
|
||||
{
|
||||
refetchOnWindowFocus: false,
|
||||
|
||||
Reference in New Issue
Block a user