mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-11 22:18:54 +08:00
feat(core): improve mobile perf (#15317)
#### PR Dependency Tree * **PR #15317** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Virtualized mobile navigation with shell navigation and interactive swipe menus; coordinated mobile back handling with interactive phases/state restoration. * Added shared auth request proxy and message-port based token handling across mobile and worker flows. * **Bug Fixes** * Hydrated remote worker error stacks for calls and observable errors. * Improved SQLite FTS/indexer and nbstore optional text handling; refined docs-search ref parsing and notification loading/retry. * **Refactor / UX** * Modal focus-preservation and pointer behavior updates; improved mobile menu controls and back gesture plugins. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -1,41 +1,21 @@
|
||||
import { NavigationGestureService } from '@affine/core/mobile/modules/navigation-gesture';
|
||||
import { MobileBackCoordinator } from '@affine/core/mobile/modules/back-coordinator';
|
||||
import { onMenuOpen } from '@blocksuite/affine/components/context-menu';
|
||||
import { useService } from '@toeverything/infra';
|
||||
import { type PropsWithChildren, useCallback, useEffect, useRef } from 'react';
|
||||
import { type PropsWithChildren, useEffect } from 'react';
|
||||
|
||||
export const BlocksuiteMenuConfigProvider = ({
|
||||
children,
|
||||
}: PropsWithChildren) => {
|
||||
const navigationGesture = useService(NavigationGestureService);
|
||||
const menuCountRef = useRef(0);
|
||||
const prevEnabledRef = useRef(false);
|
||||
|
||||
const handleMenuState = useCallback(() => {
|
||||
const currentCount = menuCountRef.current + 1;
|
||||
menuCountRef.current = currentCount;
|
||||
|
||||
if (currentCount === 1) {
|
||||
prevEnabledRef.current = navigationGesture.enabled$.value;
|
||||
if (prevEnabledRef.current) {
|
||||
navigationGesture.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
return () => {
|
||||
const currentCount = menuCountRef.current - 1;
|
||||
menuCountRef.current = currentCount;
|
||||
|
||||
if (currentCount === 0 && prevEnabledRef.current) {
|
||||
navigationGesture.setEnabled(true);
|
||||
}
|
||||
};
|
||||
}, [navigationGesture]);
|
||||
const coordinator = useService(MobileBackCoordinator);
|
||||
|
||||
useEffect(() => {
|
||||
return onMenuOpen(() => {
|
||||
return handleMenuState();
|
||||
return coordinator.registerVisual({
|
||||
interactive: false,
|
||||
handle: () => false,
|
||||
}).dispose;
|
||||
});
|
||||
}, [handleMenuState]);
|
||||
}, [coordinator]);
|
||||
|
||||
return children;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user