This commit is contained in:
Ren Amamiya
2023-06-25 20:36:19 +07:00
parent fe25dbaed0
commit 6af0b453e3
25 changed files with 183 additions and 114 deletions

View File

@@ -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 };
}

View File

@@ -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,