From 1dd65ab8e91ad3fb52a277625d8877c2db31ffdd Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 7 Feb 2025 15:35:16 +0000 Subject: [PATCH] add lang select to right nav if left nav is minimal --- src/view/shell/desktop/RightNav.tsx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/view/shell/desktop/RightNav.tsx b/src/view/shell/desktop/RightNav.tsx index 433ad546a5..510d505cd8 100644 --- a/src/view/shell/desktop/RightNav.tsx +++ b/src/view/shell/desktop/RightNav.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import {useEffect, useState} from 'react' import {View} from 'react-native' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -17,6 +17,7 @@ import { useTheme, web, } from '#/alf' +import {AppLanguageDropdown} from '#/components/AppLanguageDropdown' import {Divider} from '#/components/Divider' import {InlineLinkText} from '#/components/Link' import {ProgressGuideList} from '#/components/ProgressGuide/List' @@ -24,16 +25,15 @@ import {Text} from '#/components/Typography' function useWebQueryParams() { const navigation = useNavigation() - const [params, setParams] = React.useState>({}) + const [params, setParams] = useState>({}) - React.useEffect(() => { + useEffect(() => { return navigation.addListener('state', e => { try { const {state} = e.data const lastRoute = state.routes[state.routes.length - 1] - const {params} = lastRoute - setParams(params) - } catch (e) {} + setParams(lastRoute.params) + } catch (err) {} }) }, [navigation, setParams]) @@ -50,7 +50,8 @@ export function DesktopRightNav({routeName}: {routeName: string}) { const webqueryParams = useWebQueryParams() const searchQuery = webqueryParams?.q const showTrending = !isSearchScreen || (isSearchScreen && !!searchQuery) - const {rightNavVisible, centerColumnOffset} = useLayoutBreakpoints() + const {rightNavVisible, centerColumnOffset, leftNavMinimal} = + useLayoutBreakpoints() if (!rightNavVisible) { return null @@ -128,6 +129,12 @@ export function DesktopRightNav({routeName}: {routeName: string}) { )} + + {!hasSession && leftNavMinimal && ( + + + + )} ) }