Skip to content

Commit

Permalink
Add 7 days stale time, return stale data while revalidating stale data
Browse files Browse the repository at this point in the history
  • Loading branch information
xbtmatt committed Nov 13, 2024
1 parent cf01ccb commit 10bc8c7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/typescript/frontend/src/hooks/use-is-user-geoblocked.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { useQuery } from "@tanstack/react-query";
import { MS_IN_ONE_DAY } from "components/charts/const";
import { isUserGeoblocked } from "utils/geolocation";

const SEVEN_DAYS_MS = 7 * MS_IN_ONE_DAY;

const useIsUserGeoblocked = () => {
const { data } = useQuery({
queryKey: ["geoblocked"],
queryFn: () => isUserGeoblocked(),
staleTime: Infinity,
staleTime: SEVEN_DAYS_MS,
placeholderData: (prev) => prev,
});

// Assume the user is geoblocked if the response hasn't completed yet.
Expand Down

0 comments on commit 10bc8c7

Please sign in to comment.