feat(workspace): priority load opened page (#5156)

This commit is contained in:
EYHN
2023-12-04 11:32:10 +00:00
parent b4b4a3b625
commit 7878ce5c2c
5 changed files with 93 additions and 31 deletions

View File

@@ -27,7 +27,10 @@ import { AffineErrorBoundary } from '../../components/affine/affine-error-bounda
import { GlobalPageHistoryModal } from '../../components/affine/page-history-modal';
import { WorkspaceHeader } from '../../components/workspace-header';
import { useRegisterBlocksuiteEditorCommands } from '../../hooks/affine/use-register-blocksuite-editor-commands';
import { useCurrentSyncEngineStatus } from '../../hooks/current/use-current-sync-engine';
import {
useCurrentSyncEngine,
useCurrentSyncEngineStatus,
} from '../../hooks/current/use-current-sync-engine';
import { useCurrentWorkspace } from '../../hooks/current/use-current-workspace';
import { useNavigateHelper } from '../../hooks/use-navigate-helper';
import { performanceRenderLogger } from '../../shared';
@@ -111,9 +114,18 @@ const DetailPageImpl = (): ReactElement => {
export const DetailPage = (): ReactElement => {
const [currentWorkspace] = useCurrentWorkspace();
const currentSyncEngineStatus = useCurrentSyncEngineStatus();
const currentSyncEngine = useCurrentSyncEngine();
const currentPageId = useAtomValue(currentPageIdAtom);
const [page, setPage] = useState<Page | null>(null);
// set sync engine priority target
useEffect(() => {
if (!currentPageId) {
return;
}
currentSyncEngine?.setPriorityRule(id => id.endsWith(currentPageId));
}, [currentPageId, currentSyncEngine, currentWorkspace]);
// load page by current page id
useEffect(() => {
if (!currentPageId) {