Skip to content

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.

fix: jump to the correct url after importing notion (#3844)

xiaodong zuocae6133f7e7a
diff --git a/apps/core/src/components/blocksuite/block-suite-page-list/utils.tsx b/apps/core/src/components/blocksuite/block-suite-page-list/utils.tsx
index 54865613c5..970c8b4c5b 100644
--- a/apps/core/src/components/blocksuite/block-suite-page-list/utils.tsx
+++ b/apps/core/src/components/blocksuite/block-suite-page-list/utils.tsx
@@ -1,4 +1,6 @@
+import { toast } from '@affine/component';
import { initEmptyPage } from '@affine/env/blocksuite';
+import { WorkspaceSubPath } from '@affine/env/workspace';
import { useBlockSuiteWorkspaceHelper } from '@toeverything/hooks/use-block-suite-workspace-helper';
import { useAtomValue, useSetAtom } from 'jotai';
import { useCallback } from 'react';
@@ -8,7 +10,7 @@ import { useNavigateHelper } from '../../../hooks/use-navigate-helper';
import type { BlockSuiteWorkspace } from '../../../shared';
export const usePageHelper = (blockSuiteWorkspace: BlockSuiteWorkspace) => {
- const { openPage } = useNavigateHelper();
+ const { openPage, jumpToSubPath } = useNavigateHelper();
const { createPage } = useBlockSuiteWorkspaceHelper(blockSuiteWorkspace);
const pageSettings = useAtomValue(pageSettingsAtom);
const isPreferredEdgeless = useCallback(
@@ -35,8 +37,25 @@ export const usePageHelper = (blockSuiteWorkspace: BlockSuiteWorkspace) => {
);
const importFileAndOpen = useCallback(async () => {
const { showImportModal } = await import('@blocksuite/blocks');
- showImportModal({ workspace: blockSuiteWorkspace });
- }, [blockSuiteWorkspace]);
+ const onSuccess = (pageIds: string[], isWorkspaceFile: boolean) => {
+ toast(
+ `Successfully imported ${pageIds.length} Page${
+ pageIds.length > 1 ? 's' : ''
+ }.`
+ );
+ if (isWorkspaceFile) {
+ jumpToSubPath(blockSuiteWorkspace.id, WorkspaceSubPath.ALL);
+ return;
+ }
+
+ if (pageIds.length === 0) {
+ return;
+ }
+ const pageId = pageIds[0];
+ openPage(blockSuiteWorkspace.id, pageId);
+ };
+ showImportModal({ workspace: blockSuiteWorkspace, onSuccess });
+ }, [blockSuiteWorkspace, openPage, jumpToSubPath]);
return {
createPage: createPageAndOpen,
createEdgeless: createEdgelessAndOpen,