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 @@ -14,9 +14,10 @@ export type DrawerItemProps = { +itemData: CommunityDrawerItemData, - +toggleExpanded: (threadID: string) => void, + +toggleExpanded?: (threadID: string) => void, +expanded: boolean, +paddingLeft: number, + +expandable?: boolean, }; const indentation = 14; @@ -28,6 +29,7 @@ expanded, toggleExpanded, paddingLeft, + expandable = true, } = props; const children = React.useMemo(() => { @@ -53,16 +55,27 @@ itemData={item} key={item.threadInfo.id} paddingLeft={paddingLeft + indentation} + expandable={expandable} /> )); - }, [expanded, hasSubchannelsButton, itemChildren, paddingLeft, threadInfo]); + }, [ + expanded, + hasSubchannelsButton, + itemChildren, + paddingLeft, + expandable, + threadInfo, + ]); const onExpandToggled = React.useCallback( - () => toggleExpanded(threadInfo.id), + () => (toggleExpanded ? toggleExpanded(threadInfo.id) : null), [toggleExpanded, threadInfo.id], ); const itemExpandButton = React.useMemo(() => { + if (!expandable) { + return null; + } if (itemChildren?.length === 0 && !hasSubchannelsButton) { return (
@@ -75,7 +88,13 @@
); - }, [itemChildren?.length, hasSubchannelsButton, onExpandToggled, expanded]); + }, [ + expandable, + itemChildren?.length, + hasSubchannelsButton, + onExpandToggled, + expanded, + ]); const Handler = useSelector(state => getCommunityDrawerItemHandler(state.navInfo.tab), @@ -108,6 +127,7 @@ export type CommunityDrawerItemChatProps = { +itemData: CommunityDrawerItemData, +paddingLeft: number, + +expandable?: boolean, }; function CommunityDrawerItemChat( diff --git a/web/sidebar/community-drawer.css b/web/sidebar/community-drawer.css --- a/web/sidebar/community-drawer.css +++ b/web/sidebar/community-drawer.css @@ -8,3 +8,7 @@ padding-bottom: 8px; align-self: flex-start; } + +.hidden { + display: none; +} diff --git a/web/sidebar/community-drawer.react.js b/web/sidebar/community-drawer.react.js --- a/web/sidebar/community-drawer.react.js +++ b/web/sidebar/community-drawer.react.js @@ -21,6 +21,7 @@ const labelStyles = ['titleLevel0', 'titleLevel1', 'titleLevel2']; function CommunityDrawer(): React.Node { + const tab = useSelector(state => state.navInfo.tab); const childThreadInfosMap = useSelector(childThreadInfos); const communities = useSelector(communityThreadSelector); const resolvedCommunities = useResolvedThreadInfos(communities); @@ -40,27 +41,48 @@ communitiesSuffixed.length === 1 ? communitiesSuffixed[0].id : null, ); - const setOpenCommunityOrClose = React.useCallback((communityID: string) => { - setOpenCommunity(open => (open === communityID ? null : communityID)); + const setOpenCommunityOrClose = React.useCallback((index: string) => { + setOpenCommunity(open => (open === index ? null : index)); }, []); - const communitiesComponents = React.useMemo( + const communitiesComponentsDefault = React.useMemo( () => drawerItemsData.map(item => ( )), [drawerItemsData, openCommunity, setOpenCommunityOrClose], ); + const communitiesComponentsCal = React.useMemo( + () => + drawerItemsData.map(item => ( + + )), + [drawerItemsData], + ); + + const defaultStyle = tab === 'calendar' ? css.hidden : null; + const calStyle = tab !== 'calendar' ? css.hidden : null; + return ( -
{communitiesComponents}
+
+
{communitiesComponentsDefault}
+
{communitiesComponentsCal}
+
); }