fix: replace window.location with router.push for client-side navigation

This commit is contained in:
Matt Van Horn 2026-04-08 00:01:30 -07:00
parent 553843ab06
commit 67ee8f4bb7
2 changed files with 5 additions and 9 deletions

View file

@ -40,19 +40,13 @@ export function UserDropdown({
await logout();
router.push("/");
router.push(getLoginPath());
router.refresh();
if (typeof window !== "undefined") {
window.location.href = getLoginPath();
}
} catch (error) {
console.error("Error during logout:", error);
await logout();
router.push("/");
router.push(getLoginPath());
router.refresh();
if (typeof window !== "undefined") {
window.location.href = getLoginPath();
}
}
};

View file

@ -1,6 +1,7 @@
"use client";
import { Download, FileQuestionMark, FileText, Loader2, PenLine, RefreshCw } from "lucide-react";
import { useRouter } from "next/navigation";
import { useCallback, useEffect, useRef, useState } from "react";
import { toast } from "sonner";
import { PlateEditor } from "@/components/editor/plate-editor";
@ -60,6 +61,7 @@ export function DocumentTabContent({ documentId, searchSpaceId, title }: Documen
const markdownRef = useRef<string>("");
const initialLoadDone = useRef(false);
const changeCountRef = useRef(0);
const router = useRouter();
const isLargeDocument = (doc?.content_size_bytes ?? 0) > LARGE_DOCUMENT_THRESHOLD;
@ -190,7 +192,7 @@ export function DocumentTabContent({ documentId, searchSpaceId, title }: Documen
variant="outline"
size="sm"
className="mt-1 gap-1.5"
onClick={() => window.location.reload()}
onClick={() => router.refresh()}
>
<RefreshCw className="size-3.5" />
Retry