Skip to content

Commit

Permalink
feat: Invalidate cache when buying domains
Browse files Browse the repository at this point in the history
  • Loading branch information
letehaha committed Feb 7, 2024
1 parent 5d95719 commit db50616
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/hooks/useDomainInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const useDomainInfo = (domain: string) => {
const connection = useSolanaConnection();

const queryFn = async () => {
console.log("useDomainInfo called");
if (!connection) return;
const { pubkey } = getDomainKeySync(domain);
const { registry, nftOwner } = await NameRegistryState.retrieve(
Expand All @@ -27,7 +26,6 @@ export const useDomainInfo = (domain: string) => {
return useQuery({
queryKey: [QueryKeys.domainInfo, domain],
queryFn,

staleTime: 1000 * 30,
});
};
1 change: 1 addition & 0 deletions src/hooks/usePyth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ export const usePyth = () => {
return useQuery({
queryKey: [],
queryFn,
staleTime: 1000 * 5,
});
};
12 changes: 12 additions & 0 deletions src/screens/Cart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { Screen } from "@src/components/Screen";
import { UiButton } from "@src/components/UiButton";
import { EmptyState } from "./EmptyState";
import { useStatusModalContext } from "@src/contexts/StatusModalContext";
import { QueryKeys, queryClient } from "@src/lib";

const getTokenAccountBalance = async (
connection: Connection,
Expand Down Expand Up @@ -173,6 +174,17 @@ export const Cart = () => {

setLoading(false);
goSuccessStep();

await queryClient.invalidateQueries({
predicate: (query: any) =>
[
QueryKeys.domainsList,
QueryKeys.domainInfo,
QueryKeys.subdomains,
QueryKeys.subdomainsFromUser,
].includes(query.queryKey[0]),
refetchType: "all",
});
} catch (err) {
setLoading(false);
handleError(err);
Expand Down

0 comments on commit db50616

Please sign in to comment.