diff --git a/web/sidebar/community-drawer-item.react.js b/web/sidebar/community-drawer-item.react.js --- a/web/sidebar/community-drawer-item.react.js +++ b/web/sidebar/community-drawer-item.react.js @@ -6,10 +6,8 @@ import type { CommunityDrawerItemData } from 'lib/utils/drawer-utils.react'; -import { - useOnClickThread, - useThreadIsActive, -} from '../selectors/thread-selectors'; +import { useThreadIsActive } from '../selectors/thread-selectors'; +import { getCommunityDrawerItemHandler } from './community-drawer-item-handlers.react'; import css from './community-drawer-item.css'; import { ExpandButton } from './expand-buttons.react'; import SubchannelsButton from './subchannels-button.react'; @@ -72,23 +70,33 @@ const isCreateMode = useSelector( state => state.navInfo.chatMode === 'create', ); - const onClick = useOnClickThread(threadInfo); - const selectItemIfNotActiveCreation = React.useCallback( + const tab = useSelector(state => state.navInfo.tab); + const Handler = React.useMemo(() => getCommunityDrawerItemHandler(tab), [ + tab, + ]); + + const [handler, setHandler] = React.useState({ + // eslint-disable-next-line no-unused-vars + onClick: event => {}, + }); + + const onClick = React.useCallback( (event: SyntheticEvent) => { if (!isCreateMode || !active) { - onClick(event); + handler.onClick(event); } }, - [isCreateMode, active, onClick], + [isCreateMode, active, handler], ); const titleLabel = classnames(css.title, css[labelStyle]); return ( <> +
{itemExpandButton} - +
{threadInfo.uiName}