fix(infra): use blocksuite api to check compatibility (#5137)

This commit is contained in:
Joooye_34
2023-11-30 16:48:13 +08:00
committed by GitHub
parent a226eb8d5f
commit 47d5f9e1c2
10 changed files with 91 additions and 57 deletions
@@ -75,6 +75,7 @@ export async function setup(store: ReturnType<typeof createStore>) {
),
}),
new Sentry.Replay(),
new Sentry.BrowserTracing(),
],
});
Sentry.setTags({
@@ -19,6 +19,7 @@ export const upgradeTips = style({
fontStyle: 'normal',
fontWeight: '400',
lineHeight: '20px',
textAlign: 'center',
});
const rotate = keyframes({
@@ -44,7 +44,7 @@ interface WorkspaceUpgradeProps {
export const WorkspaceUpgrade = function WorkspaceUpgrade(
props: WorkspaceUpgradeProps
) {
const [upgradeState, , upgradeWorkspace, newWorkspaceId] =
const [upgradeState, error, upgradeWorkspace, newWorkspaceId] =
useUpgradeWorkspace(props.migration);
const t = useAFFiNEI18N();
@@ -75,7 +75,7 @@ export const WorkspaceUpgrade = function WorkspaceUpgrade(
<div className={styles.upgradeBox}>
<AffineShapeIcon width={180} height={180} />
<p className={styles.upgradeTips}>
{t[UPGRADE_TIPS_KEYS[upgradeState]]()}
{error ? error.message : t[UPGRADE_TIPS_KEYS[upgradeState]]()}
</p>
<Button
data-testid="upgrade-workspace-button"
@@ -164,7 +164,8 @@ export const DetailPage = (): ReactElement => {
});
}
return <DetailPageImpl />;
// Add a key to force rerender when page changed, to avoid some lifecycle issues.
return <DetailPageImpl key={currentPageId} />;
};
export const loader: LoaderFunction = async () => {
@@ -8,6 +8,7 @@ import {
import type { MigrationPoint } from '@toeverything/infra/blocksuite';
import {
checkWorkspaceCompatibility,
fixWorkspaceVersion,
guidCompatibilityFix,
} from '@toeverything/infra/blocksuite';
import { useSetAtom } from 'jotai';
@@ -54,6 +55,7 @@ export const loader: LoaderFunction = async args => {
workspaceLoaderLogger.info('workspace loaded');
guidCompatibilityFix(workspace.doc);
fixWorkspaceVersion(workspace.doc);
return checkWorkspaceCompatibility(workspace);
};