mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
fix(core): incorrect blocksuite data format (#4039)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { PageMeta, Workspace } from '@blocksuite/store';
|
||||
import { createIndexeddbStorage } from '@blocksuite/store';
|
||||
import type { createStore, WritableAtom } from 'jotai/vanilla';
|
||||
import { Array as YArray, Doc as YDoc, Map as YMap } from 'yjs';
|
||||
|
||||
export async function buildShowcaseWorkspace(
|
||||
workspace: Workspace,
|
||||
@@ -27,7 +28,9 @@ export async function buildShowcaseWorkspace(
|
||||
'affine:bookmark': 1,
|
||||
'affine:database': 2,
|
||||
};
|
||||
workspace.doc.getMap('meta').set('blockVersions', showcaseWorkspaceVersions);
|
||||
workspace.doc
|
||||
.getMap('meta')
|
||||
.set('blockVersions', new YMap(Object.entries(showcaseWorkspaceVersions)));
|
||||
const prototypes = {
|
||||
tags: {
|
||||
options: [
|
||||
@@ -201,7 +204,6 @@ import { applyUpdate, encodeStateAsUpdate } from 'yjs';
|
||||
const migrationOrigin = 'affine-migration';
|
||||
|
||||
import type { Schema } from '@blocksuite/store';
|
||||
import { Array as YArray, Doc as YDoc, Map as YMap } from 'yjs';
|
||||
|
||||
type XYWH = [number, number, number, number];
|
||||
|
||||
@@ -495,7 +497,11 @@ const upgradeV2ToV3 = async (options: UpgradeOptions): Promise<boolean> => {
|
||||
const spaces = rootDoc.getMap('spaces') as YMap<any>;
|
||||
const meta = rootDoc.getMap('meta') as YMap<unknown>;
|
||||
const versions = meta.get('blockVersions') as YMap<number>;
|
||||
if (versions.get('affine:database') === 3) {
|
||||
if ('affine:database' in versions) {
|
||||
if (versions['affine:database'] === 3) {
|
||||
return false;
|
||||
}
|
||||
} else if (versions.get('affine:database') === 3) {
|
||||
return false;
|
||||
}
|
||||
const schema = options.getSchema();
|
||||
@@ -516,7 +522,12 @@ const upgradeV2ToV3 = async (options: UpgradeOptions): Promise<boolean> => {
|
||||
space
|
||||
);
|
||||
});
|
||||
versions.set('affine:database', 3);
|
||||
if ('affine:database' in versions) {
|
||||
versions['affine:database'] = 3;
|
||||
meta.set('blockVersions', new YMap(Object.entries(versions)));
|
||||
} else {
|
||||
versions.set('affine:database', 3);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user