MCPcopy Create free account
hub / github.com/WardAnalytics/WardGraph / RedirectSharedGraph

Function RedirectSharedGraph

src/templates/RedirectShortUrl.tsx:6–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4import RedirectTemplate from "./RedirectTemplate";
5
6const RedirectSharedGraph: FC = () => {
7 const { uid: sharedGraphID } = useParams<{ uid: string }>();
8 const { isAuthenticated, isLoading, user } = useAuthState();
9
10 const userID = useMemo(() => {
11 return user ? user.uid : "";
12 }, [user]);
13
14 const navigate = useNavigate();
15
16 useEffect(() => {
17 // If the user is loading, it does nothing
18 if (isLoading) {
19 return;
20 }
21
22 sessionStorage.removeItem("focusedAddressData");
23
24 // If the user is authenticated, it redirects to the graph on user account, otherwise, it redirects to the public graph
25 if (isAuthenticated) {
26 navigate(`/${userID}/graph/${sharedGraphID}`);
27 } else {
28 navigate(`/public/graph/${sharedGraphID}`);
29 }
30
31 }, [isLoading, userID])
32
33 return <RedirectTemplate title="Redirecting to the graph..." />;
34};
35
36export default RedirectSharedGraph;

Callers

nothing calls this directly

Calls 1

useAuthStateFunction · 0.85

Tested by

no test coverage detected