Skip to content

Commit

Permalink
fix(core): open page info modal error (#8396)
Browse files Browse the repository at this point in the history
  • Loading branch information
EYHN committed Sep 26, 2024
1 parent bd9ae3d commit 4295f5e
Showing 1 changed file with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,24 @@ import {
import { DocInfoService } from '@affine/core/modules/doc-info';
import { DocsSearchService } from '@affine/core/modules/docs-search';
import { useI18n } from '@affine/i18n';
import type { Doc } from '@toeverything/infra';
import {
DocsService,
FrameworkScope,
LiveData,
useLiveData,
useService,
useServices,
} from '@toeverything/infra';
import { Suspense, useCallback, useContext, useMemo, useRef } from 'react';
import {
Suspense,
useCallback,
useContext,
useEffect,
useMemo,
useRef,
useState,
} from 'react';

import { BlocksuiteHeaderTitle } from '../../../blocksuite/block-suite-header/title';
import { managerContext } from '../common';
Expand All @@ -31,10 +42,26 @@ import { TimeRow } from './time-row';
export const InfoModal = () => {
const modal = useService(DocInfoService).modal;
const docId = useLiveData(modal.docId$);
const docsService = useService(DocsService);

const [doc, setDoc] = useState<Doc | null>(null);
useEffect(() => {
if (!docId) return;
const docRef = docsService.open(docId);
setDoc(docRef.doc);
return () => {
docRef.release();
setDoc(null);
};
}, [docId, docsService]);

if (!docId) return null;
if (!doc || !docId) return null;

return <InfoModalOpened docId={docId} />;
return (
<FrameworkScope scope={doc.scope}>
<InfoModalOpened docId={docId} />
</FrameworkScope>
);
};

const InfoModalOpened = ({ docId }: { docId: string }) => {
Expand Down

0 comments on commit 4295f5e

Please sign in to comment.