diff --git a/src/App.tsx b/src/App.tsx index 821fe0062..f56f6588d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -58,6 +58,7 @@ import {Shell} from '#/view/shell' import {atoms as a, ThemeProvider as Alf} from '#/alf' import {useColorModeTheme} from '#/alf/util/useColorModeTheme' import {Provider as ContextMenuProvider} from '#/components/ContextMenu' +import {EphemeralAccountSwitcherRootScope} from '#/components/EphemeralAccountSwitcher' import {useLandingEntry} from '#/components/hooks/useLandingEntry' import {Provider as IntentDialogProvider} from '#/components/intents/IntentDialogs' import {Provider as LightboxStateProvider} from '#/components/Lightbox/state' @@ -181,7 +182,9 @@ function InnerApp() { - + + + diff --git a/src/App.web.tsx b/src/App.web.tsx index cb428001b..c5d4f6802 100644 --- a/src/App.web.tsx +++ b/src/App.web.tsx @@ -62,6 +62,7 @@ import {Shell} from '#/view/shell/index' import {ThemeProvider as Alf} from '#/alf' import {useColorModeTheme} from '#/alf/util/useColorModeTheme' import {Provider as ContextMenuProvider} from '#/components/ContextMenu' +import {EphemeralAccountSwitcherRootScope} from '#/components/EphemeralAccountSwitcher' import {useLandingEntry} from '#/components/hooks/useLandingEntry' import {Provider as IntentDialogProvider} from '#/components/intents/IntentDialogs' import {Provider as LightboxStateProvider} from '#/components/Lightbox/state' @@ -274,7 +275,9 @@ function InnerApp() { - + + + diff --git a/src/components/EphemeralAccountSwitcher.tsx b/src/components/EphemeralAccountSwitcher.tsx index 23ea0553c..baf38229e 100644 --- a/src/components/EphemeralAccountSwitcher.tsx +++ b/src/components/EphemeralAccountSwitcher.tsx @@ -155,6 +155,26 @@ export function EphemeralAccountSwitcherScope({ ) } +/** + * Provides one shared account/profile query and prompt control for the active + * app shell. Single-account sessions skip the provider entirely. + */ +export function EphemeralAccountSwitcherRootScope({ + children, +}: React.PropsWithChildren) { + const {accounts, currentAccount} = useSession() + + if (accounts.length < 2 || !currentAccount) return children + + return ( + + {children} + + ) +} + export function useEphemeralAccountSwitcher() { const context = useContext(EphemeralAccountSwitcherContext) if (!context) { @@ -265,11 +285,7 @@ export function EphemeralAccountSwitcherMenu({ } return ( - + {({props: menuTriggerProps}) => ( diff --git a/src/components/PostControls/index.tsx b/src/components/PostControls/index.tsx index fe01e79bf..c779f21b2 100644 --- a/src/components/PostControls/index.tsx +++ b/src/components/PostControls/index.tsx @@ -41,10 +41,7 @@ import { } from '#/state/shell/progress-guide' import * as userActionHistory from '#/state/userActionHistory' import {atoms as a, useBreakpoints, useTheme} from '#/alf' -import { - EphemeralAccountSwitcherFromScope, - EphemeralAccountSwitcherScope, -} from '#/components/EphemeralAccountSwitcher' +import {EphemeralAccountSwitcherFromScope} from '#/components/EphemeralAccountSwitcher' import {Reply as Bubble} from '#/components/icons/Reply' import {useFormatPostStatCount} from '#/components/PostControls/util' import * as Skele from '#/components/Skeleton' @@ -685,23 +682,7 @@ function PostControlsInner({ ) } -type PostControlsProps = Parameters[0] - -const PostControls = memo(function PostControls(props: PostControlsProps) { - const {accounts, currentAccount} = useSession() - - if (accounts.length < 2 || !currentAccount) { - return - } - - return ( - - - - ) -}) +const PostControls = memo(PostControlsInner) export {PostControls} export function PostControlsSkeleton({