mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 14:27:02 +08:00
refactor: workspace header (#1880)
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
import { getLoginStorage } from '@affine/workspace/affine/login';
|
||||
import type { AffinePublicWorkspace } from '@affine/workspace/type';
|
||||
import { WorkspaceFlavour } from '@affine/workspace/type';
|
||||
import { createEmptyBlockSuiteWorkspace } from '@affine/workspace/utils';
|
||||
import { atom } from 'jotai';
|
||||
|
||||
import { BlockSuiteWorkspace } from '../../shared';
|
||||
import { affineApis } from '../../shared/apis';
|
||||
|
||||
function createPublicWorkspace(workspaceId: string, binary: ArrayBuffer) {
|
||||
function createPublicWorkspace(
|
||||
workspaceId: string,
|
||||
binary: ArrayBuffer
|
||||
): AffinePublicWorkspace {
|
||||
const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace(
|
||||
workspaceId,
|
||||
(k: string) =>
|
||||
@@ -22,12 +27,18 @@ function createPublicWorkspace(workspaceId: string, binary: ArrayBuffer) {
|
||||
blockSuiteWorkspace.awarenessStore.setFlag('enable_edgeless_toolbar', false);
|
||||
blockSuiteWorkspace.awarenessStore.setFlag('enable_slash_menu', false);
|
||||
blockSuiteWorkspace.awarenessStore.setFlag('enable_drag_handle', false);
|
||||
return blockSuiteWorkspace;
|
||||
return {
|
||||
flavour: WorkspaceFlavour.PUBLIC,
|
||||
id: workspaceId,
|
||||
blockSuiteWorkspace,
|
||||
// maybe we can add some sync providers here
|
||||
providers: [],
|
||||
};
|
||||
}
|
||||
|
||||
export const publicWorkspaceIdAtom = atom<string | null>(null);
|
||||
export const publicWorkspacePageIdAtom = atom<string | null>(null);
|
||||
export const publicPageBlockSuiteAtom = atom<Promise<BlockSuiteWorkspace>>(
|
||||
export const publicPageBlockSuiteAtom = atom<Promise<AffinePublicWorkspace>>(
|
||||
async get => {
|
||||
const workspaceId = get(publicWorkspaceIdAtom);
|
||||
const pageId = get(publicWorkspacePageIdAtom);
|
||||
@@ -41,7 +52,7 @@ export const publicPageBlockSuiteAtom = atom<Promise<BlockSuiteWorkspace>>(
|
||||
return createPublicWorkspace(workspaceId, binary);
|
||||
}
|
||||
);
|
||||
export const publicBlockSuiteAtom = atom<Promise<BlockSuiteWorkspace>>(
|
||||
export const publicWorkspaceAtom = atom<Promise<AffinePublicWorkspace>>(
|
||||
async get => {
|
||||
const workspaceId = get(publicWorkspaceIdAtom);
|
||||
if (!workspaceId) {
|
||||
|
||||
Reference in New Issue
Block a user