mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-30 05:34:21 +03:00
fix(infra): page id compat fix for page ids in workspace.meta (#4950)
since we strip `page:` in keys of workspacedoc.spaces, we should also strip the prefix in meta.pages as well.
This commit is contained in:
parent
ddd7cab414
commit
791eb75ca8
@ -670,8 +670,17 @@ async function upgradeV2ToV3(options: UpgradeOptions): Promise<boolean> {
|
|||||||
export function guidCompatibilityFix(rootDoc: YDoc) {
|
export function guidCompatibilityFix(rootDoc: YDoc) {
|
||||||
let changed = false;
|
let changed = false;
|
||||||
transact(rootDoc, () => {
|
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>;
|
const spaces = rootDoc.getMap('spaces') as YMap<YDoc>;
|
||||||
spaces.forEach((doc: YDoc, pageId: string) => {
|
spaces?.forEach((doc: YDoc, pageId: string) => {
|
||||||
if (pageId.includes(':')) {
|
if (pageId.includes(':')) {
|
||||||
const newPageId = pageId.split(':').at(-1) ?? pageId;
|
const newPageId = pageId.split(':').at(-1) ?? pageId;
|
||||||
const newDoc = new YDoc();
|
const newDoc = new YDoc();
|
||||||
|
Loading…
Reference in New Issue
Block a user