fix: blob fetch and state syncing between tabs (#1287)

This commit is contained in:
Himself65
2023-03-02 21:48:35 -06:00
committed by GitHub
parent 2a955d1391
commit 4d8d128539
6 changed files with 28 additions and 16 deletions

View File

@@ -1,17 +1,10 @@
import { atom } from 'jotai';
import { createStore } from 'jotai/index';
import { atomWithStorage } from 'jotai/utils';
import { createStore } from 'jotai';
import { unstable_batchedUpdates } from 'react-dom';
// workspace necessary atoms
export const currentWorkspaceIdAtom = atomWithStorage<string | null>(
'affine-current-workspace-id',
null
);
export const currentPageIdAtom = atomWithStorage<string | null>(
'affine-current-page-id',
null
);
export const currentWorkspaceIdAtom = atom<string | null>(null);
export const currentPageIdAtom = atom<string | null>(null);
// If the workspace is locked, it means that the user maybe updating the workspace
// from local to remote or vice versa
export const workspaceLockAtom = atom(false);

View File

@@ -16,7 +16,10 @@ export const publicBlockSuiteAtom = atom<Promise<BlockSuiteWorkspace>>(
throw new Error('No workspace id');
}
const binary = await apis.downloadWorkspace(workspaceId, true);
const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace(workspaceId);
const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace(
workspaceId,
(_: string) => undefined
);
BlockSuiteWorkspace.Y.applyUpdate(
blockSuiteWorkspace.doc,
new Uint8Array(binary)