Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: firefox/safari to redirect to /explore in HomeLayout (#3001)

Zhiyuan Zheng51a793461634
diff --git a/web/src/layouts/HomeLayout.tsx b/web/src/layouts/HomeLayout.tsx
index 363446949..2bf63c932 100644
--- a/web/src/layouts/HomeLayout.tsx
+++ b/web/src/layouts/HomeLayout.tsx
@@ -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";
@@ -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">