mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 10:22:55 +08:00
refactor: new provider (#4900)
This commit is contained in:
@@ -15,7 +15,6 @@ import {
|
||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||
import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import type { Page } from '@blocksuite/store';
|
||||
import type { DragEndEvent } from '@dnd-kit/core';
|
||||
import {
|
||||
DndContext,
|
||||
@@ -27,7 +26,6 @@ import {
|
||||
useSensors,
|
||||
} from '@dnd-kit/core';
|
||||
import { useBlockSuitePageMeta } from '@toeverything/hooks/use-block-suite-page-meta';
|
||||
import { loadPage } from '@toeverything/hooks/use-block-suite-workspace-page';
|
||||
import { currentWorkspaceIdAtom } from '@toeverything/infra/atom';
|
||||
import { useAtom, useAtomValue, useSetAtom } from 'jotai';
|
||||
import type { PropsWithChildren, ReactNode } from 'react';
|
||||
@@ -117,30 +115,6 @@ type WorkspaceLayoutProps = {
|
||||
incompatible?: boolean;
|
||||
};
|
||||
|
||||
// fix https://github.com/toeverything/AFFiNE/issues/4825
|
||||
function useLoadWorkspacePages() {
|
||||
const [currentWorkspace] = useCurrentWorkspace();
|
||||
const pageMetas = useBlockSuitePageMeta(currentWorkspace.blockSuiteWorkspace);
|
||||
|
||||
useEffect(() => {
|
||||
if (currentWorkspace) {
|
||||
const timer = setTimeout(() => {
|
||||
const pageIds = pageMetas.map(meta => meta.id);
|
||||
const pages = pageIds
|
||||
.map(id => currentWorkspace.blockSuiteWorkspace.getPage(id))
|
||||
.filter((p): p is Page => !!p);
|
||||
pages.forEach(page => {
|
||||
loadPage(page, -10).catch(e => console.error(e));
|
||||
});
|
||||
}, 10 * 1000); // load pages after 10s
|
||||
return () => {
|
||||
clearTimeout(timer);
|
||||
};
|
||||
}
|
||||
return;
|
||||
}, [currentWorkspace, pageMetas]);
|
||||
}
|
||||
|
||||
export const WorkspaceLayout = function WorkspacesSuspense({
|
||||
children,
|
||||
incompatible = false,
|
||||
@@ -255,8 +229,6 @@ export const WorkspaceLayoutInner = ({
|
||||
const inTrashPage = pageMeta?.trash ?? false;
|
||||
const setMainContainer = useSetAtom(mainContainerAtom);
|
||||
|
||||
useLoadWorkspacePages();
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* This DndContext is used for drag page from all-pages list into a folder in sidebar */}
|
||||
|
||||
Reference in New Issue
Block a user