From 6883cc2ded500c21394069fc156ef0a0d49f3334 Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Tue, 31 Dec 2024 10:19:25 +0800 Subject: [PATCH] fix(electron): page history api fetch issue (#9440) --- .../core/src/components/affine/page-history-modal/data.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/frontend/core/src/components/affine/page-history-modal/data.ts b/packages/frontend/core/src/components/affine/page-history-modal/data.ts index e46c04c4e..a74547a4a 100644 --- a/packages/frontend/core/src/components/affine/page-history-modal/data.ts +++ b/packages/frontend/core/src/components/affine/page-history-modal/data.ts @@ -70,7 +70,8 @@ export const useDocSnapshotList = (workspaceId: string, pageDocId: string) => { }; const snapshotFetcher = async ( - [workspaceId, pageDocId, ts]: [ + [fetchService, workspaceId, pageDocId, ts]: [ + FetchService, workspaceId: string, pageDocId: string, ts: string, @@ -79,7 +80,7 @@ const snapshotFetcher = async ( if (!ts) { return null; } - const res = await fetch( + const res = await fetchService.fetch( `/api/workspaces/${workspaceId}/docs/${pageDocId}/histories/${ts}` ); @@ -132,9 +133,10 @@ export const usePageHistory = ( pageDocId: string, ts?: string ) => { + const fetchService = useService(FetchService); // snapshot should be immutable. so we use swr immutable to disable revalidation const { data } = useSWRImmutable( - [workspaceId, pageDocId, ts], + [fetchService, workspaceId, pageDocId, ts], { fetcher: snapshotFetcher, suspense: false,