Merge pull request #1182 from mvanhorn/fix/replace-window-location-with-router

fix: replace window.location with router.push for client-side navigation
This commit is contained in:
Rohan Verma 2026-04-08 02:01:44 -07:00 committed by GitHub
commit 588e232588
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 9 deletions

View file

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

View file

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