There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix: blob fetch and state syncing between tabs (#1287)
Himself654d8d12853902
diff --git a/apps/web/src/atoms/index.ts b/apps/web/src/atoms/index.tsindex d62ec0baf0..e9d5126345 100644--- a/apps/web/src/atoms/index.ts+++ b/apps/web/src/atoms/index.ts@@ -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 versaexport const workspaceLockAtom = atom(false);diff --git a/apps/web/src/atoms/public-workspace/index.ts b/apps/web/src/atoms/public-workspace/index.tsindex bf13b09882..9e5ffbeb15 100644--- a/apps/web/src/atoms/public-workspace/index.ts+++ b/apps/web/src/atoms/public-workspace/index.ts@@ -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)diff --git a/apps/web/src/hooks/use-workspaces.ts b/apps/web/src/hooks/use-workspaces.tsindex 0d515492cd..8f53182a64 100644--- a/apps/web/src/hooks/use-workspaces.ts+++ b/apps/web/src/hooks/use-workspaces.ts@@ -38,7 +38,10 @@ globalThis.dataCenter = dataCenter;function createRemLocalWorkspace(name: string) {const id = nanoid();- const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace(id);+ const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace(+ id,+ (_: string) => undefined+ );blockSuiteWorkspace.meta.setName(name);const workspace: LocalWorkspace = {flavour: RemWorkspaceFlavour.LOCAL,diff --git a/apps/web/src/pages/_debug/broadcast.dev.tsx b/apps/web/src/pages/_debug/broadcast.dev.tsxindex 8bdddee48a..d3e1e3cf22 100644--- a/apps/web/src/pages/_debug/broadcast.dev.tsx+++ b/apps/web/src/pages/_debug/broadcast.dev.tsx@@ -19,7 +19,11 @@ declare global {const BroadcastPage: React.FC = () => {const blockSuiteWorkspace = useMemo(- () => createEmptyBlockSuiteWorkspace('broadcast-test'),+ () =>+ createEmptyBlockSuiteWorkspace(+ 'broadcast-test',+ (_: string) => undefined+ ),[]);const [provider, setProvider] = useState<BroadCastChannelProvider | null>(diff --git a/apps/web/src/pages/preview/[previewId].tsx b/apps/web/src/pages/preview/[previewId].tsxindex a0755918dd..359add5df7 100644--- a/apps/web/src/pages/preview/[previewId].tsx+++ b/apps/web/src/pages/preview/[previewId].tsx@@ -29,7 +29,10 @@ const PreviewPage: NextPage<PreviewPageProps> = ({const [blockSuiteWorkspace, setBlockSuiteWorkspace] =useState<BlockSuiteWorkspace | null>(null);useEffect(() => {- const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace('preview');+ const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace(+ 'preview',+ (_: string) => undefined+ );blockSuiteWorkspace.signals.pageAdded.once(() => {setBlockSuiteWorkspace(blockSuiteWorkspace);});diff --git a/apps/web/src/plugins/local/index.tsx b/apps/web/src/plugins/local/index.tsxindex eceb8c4b2a..f3f83c841f 100644--- a/apps/web/src/plugins/local/index.tsx+++ b/apps/web/src/plugins/local/index.tsx@@ -92,7 +92,10 @@ export const LocalPlugin: WorkspacePlugin<RemWorkspaceFlavour.LOCAL> = {if (config.enableIndexedDBProvider) {const workspaces = await Promise.all(ids.map(id => {- const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace(id);+ const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace(+ id,+ (_: string) => undefined+ );const workspace: LocalWorkspace = {id,flavour: RemWorkspaceFlavour.LOCAL,@@ -139,7 +142,10 @@ export const LocalPlugin: WorkspacePlugin<RemWorkspaceFlavour.LOCAL> = {}logger.info('no local workspace found, create a new one');const workspaceId = nanoid();- const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace(workspaceId);+ const blockSuiteWorkspace = createEmptyBlockSuiteWorkspace(+ workspaceId,+ (_: string) => undefined+ );blockSuiteWorkspace.meta.setName('Untitled Workspace');localStorage.setItem(kStoreKey, JSON.stringify([workspaceId]));blockSuiteWorkspace.createPage(nanoid());