fix(infra): compatibility logic follow blocksuite (#5143)

This commit is contained in:
Joooye_34
2023-11-30 23:01:38 +08:00
committed by GitHub
parent dc279d062b
commit 246e16c6c0
2 changed files with 19 additions and 6 deletions

View File

@@ -63,11 +63,24 @@ export function checkWorkspaceCompatibility(
return MigrationPoint.BlockVersion;
}
try {
workspace.meta.validateVersion(workspace);
} catch (e) {
console.info('validateVersion error', e);
return MigrationPoint.BlockVersion;
// TODO: Catch compatibility error from blocksuite to show upgrade page.
// Temporarily follow the check logic of blocksuite.
if ((workspace.meta.pages?.length ?? 0) <= 1) {
try {
workspace.meta.validateVersion(workspace);
} catch (e) {
console.info('validateVersion error', e);
return MigrationPoint.BlockVersion;
}
}
// From v2, we depend on blocksuite to check and migrate data.
const blockVersions = workspace.meta.blockVersions;
for (const [flavour, version] of Object.entries(blockVersions ?? {})) {
const schema = workspace.schema.flavourSchemaMap.get(flavour);
if (schema?.version !== version) {
return MigrationPoint.BlockVersion;
}
}
return null;

View File

@@ -75,7 +75,7 @@ export const Component = (): ReactElement => {
const migration = useLoaderData() as MigrationPoint | undefined;
return (
<AffineErrorBoundary height="100vh">
<AffineErrorBoundary key={params.workspaceId} height="100vh">
<WorkspaceLayout migration={migration}>
<Outlet />
</WorkspaceLayout>