mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-18 18:41:52 +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:
@@ -39,14 +39,18 @@ export const Component = ({
|
||||
defaultIndexRoute = 'all',
|
||||
children,
|
||||
fallback,
|
||||
createErrorFallback,
|
||||
}: {
|
||||
defaultIndexRoute?: string;
|
||||
children?: ReactNode;
|
||||
fallback?: ReactNode;
|
||||
createErrorFallback?: (retry: () => void) => ReactNode;
|
||||
}) => {
|
||||
// navigating and creating may be slow, to avoid flickering, we show workspace fallback
|
||||
const [navigating, setNavigating] = useState(true);
|
||||
const [creating, setCreating] = useState(false);
|
||||
const [createError, setCreateError] = useState(false);
|
||||
const [createAttempt, setCreateAttempt] = useState(0);
|
||||
const authService = useService(AuthService);
|
||||
const defaultServerService = useService(DefaultServerService);
|
||||
|
||||
@@ -118,6 +122,9 @@ export const Component = ({
|
||||
}
|
||||
} else {
|
||||
if (list.length === 0) {
|
||||
if (BUILD_CONFIG.isMobileEdition && enableLocalWorkspace) {
|
||||
return;
|
||||
}
|
||||
setNavigating(false);
|
||||
return;
|
||||
}
|
||||
@@ -151,7 +158,12 @@ export const Component = ({
|
||||
return;
|
||||
}
|
||||
|
||||
createFirstAppData(workspacesService)
|
||||
const creation = createFirstAppData(workspacesService);
|
||||
if (!creation) return;
|
||||
|
||||
setCreateError(false);
|
||||
setCreating(true);
|
||||
creation
|
||||
.then(createdWorkspace => {
|
||||
if (createdWorkspace) {
|
||||
if (createdWorkspace.defaultPageId) {
|
||||
@@ -166,21 +178,29 @@ export const Component = ({
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Failed to create first app data', err);
|
||||
setCreateError(true);
|
||||
})
|
||||
.finally(() => {
|
||||
setCreating(false);
|
||||
});
|
||||
}, [
|
||||
jumpToPage,
|
||||
jumpToSignIn,
|
||||
openPage,
|
||||
workspacesService,
|
||||
loggedIn,
|
||||
listIsLoading,
|
||||
list,
|
||||
enableLocalWorkspace,
|
||||
createAttempt,
|
||||
]);
|
||||
|
||||
const retryCreate = useCallback(() => {
|
||||
setCreateAttempt(attempt => attempt + 1);
|
||||
}, []);
|
||||
|
||||
if (createError && createErrorFallback) {
|
||||
return createErrorFallback(retryCreate);
|
||||
}
|
||||
|
||||
if (navigating || creating) {
|
||||
return fallback ?? <AppContainer fallback />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user