Skip to content

Commit

Permalink
fix: firefox/safari to redirect to /explore in HomeLayout (#3001)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhzy0077 committed Feb 26, 2024
1 parent 8d08cfe commit 51a7934
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions web/src/layouts/HomeLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, IconButton, Tooltip } from "@mui/joy";
import classNames from "classnames";
import { Suspense } from "react";
import { Suspense, useEffect } from "react";
import { Outlet, useLocation } from "react-router-dom";
import useLocalStorage from "react-use/lib/useLocalStorage";
import Icon from "@/components/Icon";
Expand All @@ -19,15 +19,16 @@ const HomeLayout = () => {
const [collapsed, setCollapsed] = useLocalStorage<boolean>("navigation-collapsed", false);

// Redirect to explore page if not logged in.
if (
!currentUser &&
([Routes.HOME, Routes.TIMELINE, Routes.RESOURCES, Routes.INBOX, Routes.ARCHIVED, Routes.SETTING] as string[]).includes(
location.pathname,
)
) {
navigateTo("/explore");
return;
}
useEffect(() => {
if (
!currentUser &&
([Routes.HOME, Routes.TIMELINE, Routes.RESOURCES, Routes.INBOX, Routes.ARCHIVED, Routes.SETTING] as string[]).includes(
location.pathname,
)
) {
navigateTo("/explore");
}
}, []);

return (
<div className="w-full min-h-full">
Expand Down

0 comments on commit 51a7934

Please sign in to comment.