Skip to content

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.

fix(infra): page id compat fix for page ids in workspace.meta (#4950)

Peng Xiao791eb75ca876
diff --git a/packages/common/infra/src/blocksuite/index.ts b/packages/common/infra/src/blocksuite/index.ts
index ec281bad7d..383f8c3bee 100644
--- a/packages/common/infra/src/blocksuite/index.ts
+++ b/packages/common/infra/src/blocksuite/index.ts
@@ -670,8 +670,17 @@ async function upgradeV2ToV3(options: UpgradeOptions): Promise<boolean> {
export function guidCompatibilityFix(rootDoc: YDoc) {
let changed = false;
transact(rootDoc, () => {
+ const meta = rootDoc.getMap('meta') as YMap<unknown>;
+ const pages = meta.get('pages') as YArray<YMap<unknown>>;
+ pages?.forEach(page => {
+ const pageId = page.get('id') as string | undefined;
+ if (pageId?.includes(':')) {
+ // remove the prefix "space:" from page id
+ page.set('id', pageId.split(':').at(-1));
+ }
+ });
const spaces = rootDoc.getMap('spaces') as YMap<YDoc>;
- spaces.forEach((doc: YDoc, pageId: string) => {
+ spaces?.forEach((doc: YDoc, pageId: string) => {
if (pageId.includes(':')) {
const newPageId = pageId.split(':').at(-1) ?? pageId;
const newDoc = new YDoc();