Skip to content

Commit

Permalink
Add check to call initial users only once in dev mode (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
heisbrot authored Feb 13, 2024
1 parent b701783 commit 663d7ea
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/contexts/ApplicationProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import FullScreenLoading from "@components/ui/FullScreenLoading";
import { useApiCall } from "@utils/api";
import { useIsMd } from "@utils/responsive";
import { getLatestNetbirdRelease } from "@utils/version";
import React, { useContext, useEffect, useMemo, useState } from "react";
import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
import { useLocalStorage } from "@/hooks/useLocalStorage";
import { User } from "@/interfaces/User";
import type { NetbirdRelease } from "@/interfaces/Version";
Expand Down Expand Up @@ -31,12 +31,16 @@ export default function ApplicationProvider({ children }: Props) {
const isMd = useIsMd();
const userRequest = useApiCall<User[]>("/users", true);
const [show, setShow] = useState(false);
const requestCalled = useRef(false);

useEffect(() => {
userRequest
.get()
.then(() => setShow(true))
.catch(() => setShow(true));
if (!requestCalled.current) {
userRequest
.get()
.then(() => setShow(true))
.catch(() => setShow(true));
requestCalled.current = true;
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

Expand Down

0 comments on commit 663d7ea

Please sign in to comment.