There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix: create a new page when refresh (#1440)
Himself65373953b8aeef
diff --git a/apps/web/src/pages/workspace/[workspaceId]/all.tsx b/apps/web/src/pages/workspace/[workspaceId]/all.tsxindex 32acc3b117..f70d21ab6d 100644--- a/apps/web/src/pages/workspace/[workspaceId]/all.tsx+++ b/apps/web/src/pages/workspace/[workspaceId]/all.tsx@@ -17,6 +17,7 @@ import { useSyncRouterWithCurrentWorkspace } from '../../../hooks/use-sync-routeimport { WorkspaceLayout } from '../../../layouts';import { WorkspacePlugins } from '../../../plugins';import { NextPageWithLayout, RemWorkspaceFlavour } from '../../../shared';+const AllPage: NextPageWithLayout = () => {const router = useRouter();const { jumpToPage } = useRouterHelper(router);@@ -27,18 +28,23 @@ const AllPage: NextPageWithLayout = () => {if (!router.isReady) {return;}- if (currentWorkspace?.blockSuiteWorkspace.isEmpty) {- // this is a new workspace, so we should redirect to the new page- const pageId = nanoid();- currentWorkspace.blockSuiteWorkspace.slots.pageAdded.once(id => {- currentWorkspace.blockSuiteWorkspace.setPageMeta(id, {- init: true,+ const id = setTimeout(() => {+ if (currentWorkspace?.blockSuiteWorkspace.isEmpty) {+ // this is a new workspace, so we should redirect to the new page+ const pageId = nanoid();+ currentWorkspace.blockSuiteWorkspace.slots.pageAdded.once(id => {+ currentWorkspace.blockSuiteWorkspace.setPageMeta(id, {+ init: true,+ });+ assertExists(pageId, id);+ jumpToPage(currentWorkspace.id, pageId);});- assertExists(pageId, id);- jumpToPage(currentWorkspace.id, pageId);- });- currentWorkspace.blockSuiteWorkspace.createPage(pageId);- }+ currentWorkspace.blockSuiteWorkspace.createPage(pageId);+ }+ }, 1000);+ return () => {+ clearTimeout(id);+ };}, [currentWorkspace, jumpToPage, router]);const onClickPage = useCallback((pageId: string, newTab?: boolean) => {diff --git a/tests/shortcuts.spec.ts b/tests/shortcuts.spec.tsindex 139021ffe1..d9576789f1 100644--- a/tests/shortcuts.spec.ts+++ b/tests/shortcuts.spec.ts@@ -10,10 +10,11 @@ test.describe('Shortcuts Modal', () => {await page.locator('[data-testid=help-island]').click();const shortcutsIcon = page.locator('[data-testid=shortcuts-icon]');+ await page.waitForTimeout(1000);expect(await shortcutsIcon.isVisible()).toEqual(true);await shortcutsIcon.click();- await page.waitForTimeout(800);+ await page.waitForTimeout(1000);const shortcutsModal = page.locator('[data-testid=shortcuts-modal]');await expect(shortcutsModal).toContainText('Keyboard Shortcuts');});