mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
fix: create a new page when refresh (#1440)
This commit is contained in:
@@ -17,6 +17,7 @@ import { useSyncRouterWithCurrentWorkspace } from '../../../hooks/use-sync-route
|
|||||||
import { WorkspaceLayout } from '../../../layouts';
|
import { WorkspaceLayout } from '../../../layouts';
|
||||||
import { WorkspacePlugins } from '../../../plugins';
|
import { WorkspacePlugins } from '../../../plugins';
|
||||||
import { NextPageWithLayout, RemWorkspaceFlavour } from '../../../shared';
|
import { NextPageWithLayout, RemWorkspaceFlavour } from '../../../shared';
|
||||||
|
|
||||||
const AllPage: NextPageWithLayout = () => {
|
const AllPage: NextPageWithLayout = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { jumpToPage } = useRouterHelper(router);
|
const { jumpToPage } = useRouterHelper(router);
|
||||||
@@ -27,18 +28,23 @@ const AllPage: NextPageWithLayout = () => {
|
|||||||
if (!router.isReady) {
|
if (!router.isReady) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (currentWorkspace?.blockSuiteWorkspace.isEmpty) {
|
const id = setTimeout(() => {
|
||||||
// this is a new workspace, so we should redirect to the new page
|
if (currentWorkspace?.blockSuiteWorkspace.isEmpty) {
|
||||||
const pageId = nanoid();
|
// this is a new workspace, so we should redirect to the new page
|
||||||
currentWorkspace.blockSuiteWorkspace.slots.pageAdded.once(id => {
|
const pageId = nanoid();
|
||||||
currentWorkspace.blockSuiteWorkspace.setPageMeta(id, {
|
currentWorkspace.blockSuiteWorkspace.slots.pageAdded.once(id => {
|
||||||
init: true,
|
currentWorkspace.blockSuiteWorkspace.setPageMeta(id, {
|
||||||
|
init: true,
|
||||||
|
});
|
||||||
|
assertExists(pageId, id);
|
||||||
|
jumpToPage(currentWorkspace.id, pageId);
|
||||||
});
|
});
|
||||||
assertExists(pageId, id);
|
currentWorkspace.blockSuiteWorkspace.createPage(pageId);
|
||||||
jumpToPage(currentWorkspace.id, pageId);
|
}
|
||||||
});
|
}, 1000);
|
||||||
currentWorkspace.blockSuiteWorkspace.createPage(pageId);
|
return () => {
|
||||||
}
|
clearTimeout(id);
|
||||||
|
};
|
||||||
}, [currentWorkspace, jumpToPage, router]);
|
}, [currentWorkspace, jumpToPage, router]);
|
||||||
const onClickPage = useCallback(
|
const onClickPage = useCallback(
|
||||||
(pageId: string, newTab?: boolean) => {
|
(pageId: string, newTab?: boolean) => {
|
||||||
|
|||||||
@@ -10,10 +10,11 @@ test.describe('Shortcuts Modal', () => {
|
|||||||
await page.locator('[data-testid=help-island]').click();
|
await page.locator('[data-testid=help-island]').click();
|
||||||
|
|
||||||
const shortcutsIcon = page.locator('[data-testid=shortcuts-icon]');
|
const shortcutsIcon = page.locator('[data-testid=shortcuts-icon]');
|
||||||
|
await page.waitForTimeout(1000);
|
||||||
expect(await shortcutsIcon.isVisible()).toEqual(true);
|
expect(await shortcutsIcon.isVisible()).toEqual(true);
|
||||||
|
|
||||||
await shortcutsIcon.click();
|
await shortcutsIcon.click();
|
||||||
await page.waitForTimeout(800);
|
await page.waitForTimeout(1000);
|
||||||
const shortcutsModal = page.locator('[data-testid=shortcuts-modal]');
|
const shortcutsModal = page.locator('[data-testid=shortcuts-modal]');
|
||||||
await expect(shortcutsModal).toContainText('Keyboard Shortcuts');
|
await expect(shortcutsModal).toContainText('Keyboard Shortcuts');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user