From ea4f5ffc8358e7020591ab94c00b2218157315b5 Mon Sep 17 00:00:00 2001 From: Joooye_34 Date: Tue, 14 Nov 2023 14:38:11 +0100 Subject: [PATCH] fix(infra): workspace migration without blockVersions (#4936) --- packages/common/infra/src/blocksuite/index.ts | 5 +++-- packages/frontend/workspace/src/atom.ts | 10 ++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/common/infra/src/blocksuite/index.ts b/packages/common/infra/src/blocksuite/index.ts index 335d137331..ec281bad7d 100644 --- a/packages/common/infra/src/blocksuite/index.ts +++ b/packages/common/infra/src/blocksuite/index.ts @@ -598,12 +598,13 @@ export async function forceUpgradePages( options: Omit ): Promise { const rootDoc = await options.getCurrentRootDoc(); + guidCompatibilityFix(rootDoc); + const spaces = rootDoc.getMap('spaces') as YMap; const meta = rootDoc.getMap('meta') as YMap; const versions = meta.get('blockVersions') as YMap; const schema = options.getSchema(); - const oldVersions = versions.toJSON(); - guidCompatibilityFix(rootDoc); + const oldVersions = versions?.toJSON() ?? {}; spaces.forEach((space: Doc) => { try { schema.upgradePage(0, oldVersions, space); diff --git a/packages/frontend/workspace/src/atom.ts b/packages/frontend/workspace/src/atom.ts index d26bc58ffd..2b9fed2c73 100644 --- a/packages/frontend/workspace/src/atom.ts +++ b/packages/frontend/workspace/src/atom.ts @@ -140,12 +140,10 @@ const fetchMetadata: FetchMetadata = async (get, { signal }) => { performanceJotaiLogger.info('%s adapter', Adapter.flavour); const { CRUD, flavour: currentFlavour } = Adapter; - if ( - Adapter.Events['app:access'] && - !(await Adapter.Events['app:access']()) - ) { - performanceJotaiLogger.info('%s app:access', Adapter.flavour); - + const appAccessFn = Adapter.Events['app:access']; + const canAccess = appAccessFn && !(await appAccessFn()); + performanceJotaiLogger.info('%s app:access', Adapter.flavour); + if (canAccess) { // skip the adapter if the user doesn't have access to it const removed = metadata.filter( meta => meta.flavour === currentFlavour