From 6e4d2eb0762fa74b2b19bf834fe96f95928c77a3 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Wed, 24 Jun 2026 03:55:41 +0530 Subject: [PATCH] fix(panels):use session aware asset requests --- .../components/editor-panel/editor-panel.tsx | 14 +------------- surfsense_web/components/editor-panel/memory.ts | 2 +- .../components/report-panel/pdf-viewer.tsx | 2 +- .../components/report-panel/report-panel.tsx | 2 +- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/surfsense_web/components/editor-panel/editor-panel.tsx b/surfsense_web/components/editor-panel/editor-panel.tsx index 75283c81f..1e29a261a 100644 --- a/surfsense_web/components/editor-panel/editor-panel.tsx +++ b/surfsense_web/components/editor-panel/editor-panel.tsx @@ -33,7 +33,7 @@ import { Separator } from "@/components/ui/separator"; import { Spinner } from "@/components/ui/spinner"; import { useMediaQuery } from "@/hooks/use-media-query"; import { useElectronAPI } from "@/hooks/use-platform"; -import { authenticatedFetch, getBearerToken, redirectToLogin } from "@/lib/auth-utils"; +import { authenticatedFetch } from "@/lib/auth-fetch"; import { inferMonacoLanguageFromPath } from "@/lib/editor-language"; import { buildBackendUrl } from "@/lib/env-config"; @@ -274,12 +274,6 @@ export function EditorPanelContent({ if (!documentId || !searchSpaceId) { throw new Error("Missing document context"); } - const token = getBearerToken(); - if (!token) { - redirectToLogin(); - return; - } - const response = await authenticatedFetch( buildBackendUrl( `/api/v1/search-spaces/${searchSpaceId}/documents/${documentId}/editor-content` @@ -417,12 +411,6 @@ export function EditorPanelContent({ if (!searchSpaceId || !documentId) { throw new Error("Missing document context"); } - const token = getBearerToken(); - if (!token) { - toast.error("Please login to save"); - redirectToLogin(); - return; - } const response = await authenticatedFetch( buildBackendUrl(`/api/v1/search-spaces/${searchSpaceId}/documents/${documentId}/save`), { diff --git a/surfsense_web/components/editor-panel/memory.ts b/surfsense_web/components/editor-panel/memory.ts index 1beb977a6..8c4dfc035 100644 --- a/surfsense_web/components/editor-panel/memory.ts +++ b/surfsense_web/components/editor-panel/memory.ts @@ -1,6 +1,6 @@ "use client"; -import { authenticatedFetch } from "@/lib/auth-utils"; +import { authenticatedFetch } from "@/lib/auth-fetch"; import { buildBackendUrl } from "@/lib/env-config"; export type MemoryScope = "user" | "team"; diff --git a/surfsense_web/components/report-panel/pdf-viewer.tsx b/surfsense_web/components/report-panel/pdf-viewer.tsx index 77d0f83a6..bc385eb53 100644 --- a/surfsense_web/components/report-panel/pdf-viewer.tsx +++ b/surfsense_web/components/report-panel/pdf-viewer.tsx @@ -6,7 +6,7 @@ import * as pdfjsLib from "pdfjs-dist"; import { type ReactNode, useCallback, useEffect, useRef, useState } from "react"; import { Button } from "@/components/ui/button"; import { Spinner } from "@/components/ui/spinner"; -import { getAuthHeaders } from "@/lib/auth-utils"; +import { getAuthHeaders } from "@/lib/auth-fetch"; pdfjsLib.GlobalWorkerOptions.workerSrc = new URL( "pdfjs-dist/build/pdf.worker.min.mjs", diff --git a/surfsense_web/components/report-panel/report-panel.tsx b/surfsense_web/components/report-panel/report-panel.tsx index 53b0c9867..1fce9848c 100644 --- a/surfsense_web/components/report-panel/report-panel.tsx +++ b/surfsense_web/components/report-panel/report-panel.tsx @@ -21,7 +21,7 @@ import { import { Spinner } from "@/components/ui/spinner"; import { useMediaQuery } from "@/hooks/use-media-query"; import { baseApiService } from "@/lib/apis/base-api.service"; -import { authenticatedFetch } from "@/lib/auth-utils"; +import { authenticatedFetch } from "@/lib/auth-fetch"; import { buildBackendUrl } from "@/lib/env-config"; function ReportPanelSkeleton() {