diff --git a/web/sidebar/app-switcher.react.js b/web/sidebar/app-switcher.react.js --- a/web/sidebar/app-switcher.react.js +++ b/web/sidebar/app-switcher.react.js @@ -8,12 +8,17 @@ unreadCount, } from 'lib/selectors/thread-selectors'; +import type { AppState } from '../redux/redux-setup.js'; import { useSelector } from '../redux/redux-utils'; import SWMansionIcon from '../SWMansionIcon.react'; import { updateNavInfoActionType } from '../types/nav-types'; import css from './left-layout-aside.css'; import NavigationPanel from './navigation-panel.react'; +function tabSelector(state: AppState) { + return state.navInfo.tab; +} + function AppSwitcher(): React.Node { const activeChatThreadID = useSelector( state => state.navInfo.activeChatThreadID, @@ -122,7 +127,7 @@ ); return ( - + {chatNavigationItem} {calendarNavigationItem} {appNavigationItem} diff --git a/web/sidebar/navigation-panel.react.js b/web/sidebar/navigation-panel.react.js --- a/web/sidebar/navigation-panel.react.js +++ b/web/sidebar/navigation-panel.react.js @@ -3,12 +3,12 @@ import classNames from 'classnames'; import * as React from 'react'; +import type { AppState } from '../redux/redux-setup.js'; import { useSelector } from '../redux/redux-utils'; -import type { NavigationTab } from '../types/nav-types'; import css from './left-layout-aside.css'; type NavigationPanelItemProps = { - +tab: NavigationTab, + +tab: string, +children: React.Node, }; @@ -17,15 +17,16 @@ return children; } -type NavigationPanelContainerProps = { +type NavigationPanelContainerProps = { + +tabSelector: AppState => T, +children: React.ChildrenArray>, }; -function NavigationPanelContainer( - props: NavigationPanelContainerProps, +function NavigationPanelContainer( + props: NavigationPanelContainerProps, ): React.Node { - const { children } = props; - const navInfo = useSelector(state => state.navInfo); + const { children, tabSelector } = props; + const currentTab = useSelector(tabSelector); const items = React.useMemo( () => @@ -37,14 +38,14 @@
{child}
); }), - [children, navInfo.tab], + [children, currentTab], ); return
{items}
; diff --git a/web/sidebar/settings-switcher.react.js b/web/sidebar/settings-switcher.react.js --- a/web/sidebar/settings-switcher.react.js +++ b/web/sidebar/settings-switcher.react.js @@ -3,10 +3,15 @@ import * as React from 'react'; import { useDispatch } from 'react-redux'; +import type { AppState } from '../redux/redux-setup.js'; import { updateNavInfoActionType } from '../types/nav-types'; import css from './left-layout-aside.css'; import NavigationPanel from './navigation-panel.react'; +function tabSelector(state: AppState) { + return state.navInfo.settingsSection; +} + function SettingsSwitcher(): React.Node { const dispatch = useDispatch(); const onClickAccountSettings = React.useCallback( @@ -30,8 +35,8 @@ ); return ( - - + + {accountSettingsNavigationItem}