mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 14:27:02 +08:00
fix(core): remove unnecessary doc loading (#10395)
This commit is contained in:
@@ -1,19 +1,11 @@
|
|||||||
import { Checkbox, Tooltip, useDraggable } from '@affine/component';
|
import { Checkbox, Tooltip, useDraggable } from '@affine/component';
|
||||||
import { type Doc, DocsService } from '@affine/core/modules/doc';
|
|
||||||
import { TagService } from '@affine/core/modules/tag';
|
import { TagService } from '@affine/core/modules/tag';
|
||||||
import type { AffineDNDData } from '@affine/core/types/dnd';
|
import type { AffineDNDData } from '@affine/core/types/dnd';
|
||||||
import { stopPropagation } from '@affine/core/utils';
|
import { stopPropagation } from '@affine/core/utils';
|
||||||
import { i18nTime } from '@affine/i18n';
|
import { i18nTime } from '@affine/i18n';
|
||||||
import { FrameworkScope, useLiveData, useService } from '@toeverything/infra';
|
import { useLiveData, useService } from '@toeverything/infra';
|
||||||
import type { ForwardedRef, PropsWithChildren } from 'react';
|
import type { ForwardedRef, PropsWithChildren } from 'react';
|
||||||
import {
|
import { forwardRef, useCallback, useEffect, useMemo } from 'react';
|
||||||
forwardRef,
|
|
||||||
useCallback,
|
|
||||||
useEffect,
|
|
||||||
useLayoutEffect,
|
|
||||||
useMemo,
|
|
||||||
useState,
|
|
||||||
} from 'react';
|
|
||||||
|
|
||||||
import { WorkbenchLink } from '../../../modules/workbench/view/workbench-link';
|
import { WorkbenchLink } from '../../../modules/workbench/view/workbench-link';
|
||||||
import {
|
import {
|
||||||
@@ -150,7 +142,7 @@ const PageListOperationsCell = ({
|
|||||||
) : null;
|
) : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const PagelistItemInner = (props: PageListItemProps) => {
|
export const PageListItem = (props: PageListItemProps) => {
|
||||||
const [displayProperties] = useAllDocDisplayProperties();
|
const [displayProperties] = useAllDocDisplayProperties();
|
||||||
const pageTitleElement = useMemo(() => {
|
const pageTitleElement = useMemo(() => {
|
||||||
return (
|
return (
|
||||||
@@ -257,29 +249,6 @@ const PagelistItemInner = (props: PageListItemProps) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PageListItem = (props: PageListItemProps) => {
|
|
||||||
const docsService = useService(DocsService);
|
|
||||||
const [doc, setDoc] = useState<Doc | null>(null);
|
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
const { doc, release } = docsService.open(props.pageId);
|
|
||||||
setDoc(doc);
|
|
||||||
return () => {
|
|
||||||
release();
|
|
||||||
};
|
|
||||||
}, [props.pageId, docsService.list, docsService]);
|
|
||||||
|
|
||||||
if (!doc) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FrameworkScope scope={doc.scope}>
|
|
||||||
<PagelistItemInner {...props} />
|
|
||||||
</FrameworkScope>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
type PageListWrapperProps = PropsWithChildren<
|
type PageListWrapperProps = PropsWithChildren<
|
||||||
Pick<PageListItemProps, 'to' | 'pageId' | 'onClick' | 'draggable'> & {
|
Pick<PageListItemProps, 'to' | 'pageId' | 'onClick' | 'draggable'> & {
|
||||||
isDragging: boolean;
|
isDragging: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user