mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat: add affine global channel (#1762)
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import type { WorkspaceFlavour } from '@affine/workspace/type';
|
||||
import { jotaiStore, jotaiWorkspacesAtom } from '@affine/workspace/atom';
|
||||
import type { EditorContainer } from '@blocksuite/editor';
|
||||
import type { Page } from '@blocksuite/store';
|
||||
import { assertExists } from '@blocksuite/store';
|
||||
import { atom, createStore } from 'jotai';
|
||||
import { atom } from 'jotai';
|
||||
import { atomWithStorage } from 'jotai/utils';
|
||||
import { unstable_batchedUpdates } from 'react-dom';
|
||||
|
||||
import { WorkspacePlugins } from '../plugins';
|
||||
import type { RemWorkspace } from '../shared';
|
||||
import type { AllWorkspace } from '../shared';
|
||||
// workspace necessary atoms
|
||||
export const currentWorkspaceIdAtom = atom<string | null>(null);
|
||||
export const currentPageIdAtom = atom<string | null>(null);
|
||||
@@ -34,19 +34,7 @@ export const openWorkspacesModalAtom = atom(false);
|
||||
export const openCreateWorkspaceModalAtom = atom(false);
|
||||
export const openQuickSearchModalAtom = atom(false);
|
||||
|
||||
export const jotaiStore = createStore();
|
||||
|
||||
type JotaiWorkspace = {
|
||||
id: string;
|
||||
flavour: WorkspaceFlavour;
|
||||
};
|
||||
|
||||
export const jotaiWorkspacesAtom = atomWithStorage<JotaiWorkspace[]>(
|
||||
'jotai-workspaces',
|
||||
[]
|
||||
);
|
||||
|
||||
export const workspacesAtom = atom<Promise<RemWorkspace[]>>(async get => {
|
||||
export const workspacesAtom = atom<Promise<AllWorkspace[]>>(async get => {
|
||||
const flavours: string[] = Object.values(WorkspacePlugins).map(
|
||||
plugin => plugin.flavour
|
||||
);
|
||||
@@ -62,7 +50,7 @@ export const workspacesAtom = atom<Promise<RemWorkspace[]>>(async get => {
|
||||
return CRUD.get(workspace.id);
|
||||
})
|
||||
);
|
||||
return workspaces.filter(workspace => workspace !== null) as RemWorkspace[];
|
||||
return workspaces.filter(workspace => workspace !== null) as AllWorkspace[];
|
||||
});
|
||||
|
||||
type View = { id: string; mode: 'page' | 'edgeless' };
|
||||
|
||||
Reference in New Issue
Block a user