mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
feat(core): new worker workspace engine (#9257)
This commit is contained in:
@@ -17,13 +17,20 @@ import type {
|
||||
WorkspaceMetadata,
|
||||
} from '@affine/core/modules/workspace';
|
||||
import { WorkspacesService } from '@affine/core/modules/workspace';
|
||||
import { FrameworkScope, useLiveData, useServices } from '@toeverything/infra';
|
||||
import {
|
||||
FrameworkScope,
|
||||
LiveData,
|
||||
useLiveData,
|
||||
useServices,
|
||||
} from '@toeverything/infra';
|
||||
import {
|
||||
type PropsWithChildren,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { map } from 'rxjs';
|
||||
|
||||
import { AppFallback } from '../../components/app-fallback';
|
||||
import { WorkspaceDialogs } from '../../dialogs';
|
||||
@@ -33,11 +40,11 @@ declare global {
|
||||
/**
|
||||
* @internal debug only
|
||||
*/
|
||||
// eslint-disable-next-line no-var
|
||||
// oxlint-disable-next-line no-var
|
||||
var currentWorkspace: Workspace | undefined;
|
||||
// eslint-disable-next-line no-var
|
||||
// oxlint-disable-next-line no-var
|
||||
var exportWorkspaceSnapshot: (docs?: string[]) => Promise<void>;
|
||||
// eslint-disable-next-line no-var
|
||||
// oxlint-disable-next-line no-var
|
||||
var importWorkspaceSnapshot: () => Promise<void>;
|
||||
interface WindowEventMap {
|
||||
'affine:workspace:change': CustomEvent<{ id: string }>;
|
||||
@@ -106,7 +113,20 @@ export const WorkspaceLayout = ({
|
||||
]);
|
||||
|
||||
const isRootDocReady =
|
||||
useLiveData(workspace?.engine.rootDocState$.map(v => v.ready)) ?? false;
|
||||
useLiveData(
|
||||
useMemo(
|
||||
() =>
|
||||
workspace
|
||||
? LiveData.from(
|
||||
workspace.engine.doc
|
||||
.docState$(workspace.id)
|
||||
.pipe(map(v => v.ready)),
|
||||
false
|
||||
)
|
||||
: null,
|
||||
[workspace]
|
||||
)
|
||||
) ?? false;
|
||||
|
||||
if (!workspace) {
|
||||
return null; // skip this, workspace will be set in layout effect
|
||||
@@ -125,10 +145,10 @@ export const WorkspaceLayout = ({
|
||||
|
||||
{/* ---- some side-effect components ---- */}
|
||||
<PeekViewManagerModal />
|
||||
{workspace?.flavour === 'local' ? (
|
||||
<LocalQuotaModal />
|
||||
) : (
|
||||
{workspace?.flavour !== 'local' ? (
|
||||
<CloudQuotaModal />
|
||||
) : (
|
||||
<LocalQuotaModal />
|
||||
)}
|
||||
<AiLoginRequiredModal />
|
||||
<WorkspaceSideEffects />
|
||||
|
||||
Reference in New Issue
Block a user