Skip to content

Commit

Permalink
fix(router): error in the back button after refreshing the first time…
Browse files Browse the repository at this point in the history
… you enter the detail page
  • Loading branch information
hamster1963 committed Nov 15, 2024
1 parent 926d45b commit 348519e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 1 addition & 4 deletions app/(main)/ClientComponents/ServerDetailClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ export default function ServerDetailClient({
}, []);

useEffect(() => {
const previousPath = sessionStorage.getItem("lastPath");
const previousPath = sessionStorage.getItem("fromMainPage");
if (previousPath) {
setHasHistory(true);
} else {
const currentPath = window.location.pathname;
sessionStorage.setItem("lastPath", currentPath);
}
}, []);

Expand Down
6 changes: 5 additions & 1 deletion components/ServerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ export default function ServerCard({
const fixedTopServerName =
getEnv("NEXT_PUBLIC_FixedTopServerName") === "true";

const saveSession = () => {
sessionStorage.setItem("fromMainPage", "true");
};

return online ? (
<Link href={`/${id}`} prefetch={true}>
<Link onClick={saveSession} href={`/${id}`} prefetch={true}>
<Card
className={cn(
"flex flex-col items-center justify-start gap-3 p-3 md:px-5 cursor-pointer",
Expand Down

0 comments on commit 348519e

Please sign in to comment.