mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
revert: use stable react (#3228)
This commit is contained in:
@@ -47,8 +47,8 @@
|
||||
"lit": "^2.7.5",
|
||||
"lottie-web": "^5.12.2",
|
||||
"next-themes": "^0.2.1",
|
||||
"react": "18.3.0-canary-1fdacbefd-20230630",
|
||||
"react-dom": "18.3.0-canary-1fdacbefd-20230630",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react-is": "^18.2.0",
|
||||
"react-resizable-panels": "^0.0.53",
|
||||
"rxjs": "^7.8.1",
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { WorkspaceFallback } from '@affine/component/workspace';
|
||||
import { DebugLogger } from '@affine/debug';
|
||||
import { WorkspaceSubPath } from '@affine/env/workspace';
|
||||
import { WorkspaceSubPath, WorkspaceVersion } from '@affine/env/workspace';
|
||||
import type { RootWorkspaceMetadataV2 } from '@affine/workspace/atom';
|
||||
import { rootWorkspacesMetadataAtom } from '@affine/workspace/atom';
|
||||
import { getWorkspace } from '@toeverything/plugin-infra/__internal__/workspace';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { useAtom } from 'jotai';
|
||||
import type { NextPage } from 'next';
|
||||
import { useRouter } from 'next/router';
|
||||
import { Suspense, useEffect } from 'react';
|
||||
|
||||
import { WorkspaceAdapters } from '../adapters/workspace';
|
||||
import { RouteLogic, useRouterHelper } from '../hooks/use-router-helper';
|
||||
import { useWorkspace } from '../hooks/use-workspace';
|
||||
import { useAppHelper } from '../hooks/use-workspaces';
|
||||
@@ -27,9 +29,46 @@ const WorkspaceLoader = (props: AllWorkspaceLoaderProps): null => {
|
||||
const IndexPageInner = () => {
|
||||
const router = useRouter();
|
||||
const { jumpToPage, jumpToSubPath } = useRouterHelper(router);
|
||||
const meta = useAtomValue(rootWorkspacesMetadataAtom);
|
||||
const [meta, setMeta] = useAtom(rootWorkspacesMetadataAtom);
|
||||
const helper = useAppHelper();
|
||||
|
||||
useEffect(() => {
|
||||
const abortController = new AbortController();
|
||||
const signal = abortController.signal;
|
||||
const createFirst = (): RootWorkspaceMetadataV2[] => {
|
||||
if (signal.aborted) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const Plugins = Object.values(WorkspaceAdapters).sort(
|
||||
(a, b) => a.loadPriority - b.loadPriority
|
||||
);
|
||||
|
||||
return Plugins.flatMap(Plugin => {
|
||||
return Plugin.Events['app:init']?.().map(
|
||||
id =>
|
||||
({
|
||||
id,
|
||||
flavour: Plugin.flavour,
|
||||
// new workspace should all support sub-doc feature
|
||||
version: WorkspaceVersion.SubDoc,
|
||||
}) satisfies RootWorkspaceMetadataV2
|
||||
);
|
||||
}).filter((ids): ids is RootWorkspaceMetadataV2 => !!ids);
|
||||
};
|
||||
|
||||
if (meta.length === 0 && localStorage.getItem('is-first-open') === null) {
|
||||
meta.push(...createFirst());
|
||||
console.info('create first workspace', meta);
|
||||
localStorage.setItem('is-first-open', 'false');
|
||||
setMeta(meta).catch(console.error);
|
||||
}
|
||||
|
||||
return () => {
|
||||
abortController.abort();
|
||||
};
|
||||
}, [meta, setMeta]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!router.isReady) {
|
||||
return;
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
"jsx": "preserve",
|
||||
"jsxImportSource": "@emotion/react",
|
||||
"incremental": true,
|
||||
"experimentalDecorators": true,
|
||||
"types": ["react/experimental"]
|
||||
"experimentalDecorators": true
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
|
||||
Reference in New Issue
Block a user