mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-26 14:58:55 +08:00
fix(electron): page history api fetch issue (#9440)
This commit is contained in:
@@ -70,7 +70,8 @@ export const useDocSnapshotList = (workspaceId: string, pageDocId: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const snapshotFetcher = async (
|
const snapshotFetcher = async (
|
||||||
[workspaceId, pageDocId, ts]: [
|
[fetchService, workspaceId, pageDocId, ts]: [
|
||||||
|
FetchService,
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
pageDocId: string,
|
pageDocId: string,
|
||||||
ts: string,
|
ts: string,
|
||||||
@@ -79,7 +80,7 @@ const snapshotFetcher = async (
|
|||||||
if (!ts) {
|
if (!ts) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const res = await fetch(
|
const res = await fetchService.fetch(
|
||||||
`/api/workspaces/${workspaceId}/docs/${pageDocId}/histories/${ts}`
|
`/api/workspaces/${workspaceId}/docs/${pageDocId}/histories/${ts}`
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -132,9 +133,10 @@ export const usePageHistory = (
|
|||||||
pageDocId: string,
|
pageDocId: string,
|
||||||
ts?: string
|
ts?: string
|
||||||
) => {
|
) => {
|
||||||
|
const fetchService = useService(FetchService);
|
||||||
// snapshot should be immutable. so we use swr immutable to disable revalidation
|
// snapshot should be immutable. so we use swr immutable to disable revalidation
|
||||||
const { data } = useSWRImmutable<ArrayBuffer | null>(
|
const { data } = useSWRImmutable<ArrayBuffer | null>(
|
||||||
[workspaceId, pageDocId, ts],
|
[fetchService, workspaceId, pageDocId, ts],
|
||||||
{
|
{
|
||||||
fetcher: snapshotFetcher,
|
fetcher: snapshotFetcher,
|
||||||
suspense: false,
|
suspense: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user