From 35a4c63c271dd509b773767cffa88e4ec404633a Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Tue, 1 Aug 2023 22:13:04 +0800 Subject: [PATCH] fix: flaky tests (#3507) --- apps/core/src/providers/modal-provider.tsx | 20 +++++++++++++------ .../src/providers/sqlite-providers.ts | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/core/src/providers/modal-provider.tsx b/apps/core/src/providers/modal-provider.tsx index 3e6709d248..a34643ece6 100644 --- a/apps/core/src/providers/modal-provider.tsx +++ b/apps/core/src/providers/modal-provider.tsx @@ -8,7 +8,13 @@ import { } from '@toeverything/plugin-infra/atom'; import { useAtom, useAtomValue, useSetAtom } from 'jotai'; import type { FC, ReactElement } from 'react'; -import { lazy, Suspense, useCallback, useTransition } from 'react'; +import { + lazy, + startTransition, + Suspense, + useCallback, + useTransition, +} from 'react'; import type { SettingAtom } from '../atoms'; import { @@ -195,11 +201,13 @@ export const AllWorkspaceModals = (): ReactElement => { setOpenCreateWorkspaceModal(false); }, [setOpenCreateWorkspaceModal])} onCreate={useCallback( - async id => { - setOpenCreateWorkspaceModal(false); - setOpenWorkspacesModal(false); - setCurrentWorkspaceId(id); - return jumpToSubPath(id, WorkspaceSubPath.ALL); + id => { + startTransition(() => { + setOpenCreateWorkspaceModal(false); + setOpenWorkspacesModal(false); + setCurrentWorkspaceId(id); + jumpToSubPath(id, WorkspaceSubPath.ALL); + }); }, [ jumpToSubPath, diff --git a/packages/workspace/src/providers/sqlite-providers.ts b/packages/workspace/src/providers/sqlite-providers.ts index 645cb6fa35..29d2915060 100644 --- a/packages/workspace/src/providers/sqlite-providers.ts +++ b/packages/workspace/src/providers/sqlite-providers.ts @@ -14,7 +14,7 @@ import { localProviderLogger as logger } from './logger'; const Y = BlockSuiteWorkspace.Y; -const sqliteOrigin = Symbol('sqlite-provider-origin'); +const sqliteOrigin = 'sqlite-provider-origin'; const createDatasource = (workspaceId: string): DatasourceDocAdapter => { if (!window.apis?.db) {