Add the ability to hide the channel sidebar

(the left one)
This commit is contained in:
brecert
2021-09-07 10:51:46 -04:00
parent 4787a2166f
commit ed56967e10
4 changed files with 76 additions and 7 deletions

View File

@@ -49,10 +49,14 @@ export function Channel({ id }: { id: string }) {
}
const MEMBERS_SIDEBAR_KEY = "sidebar_members";
const CHANNELS_SIDEBAR_KEY = "sidebar_channels";
const TextChannel = observer(({ channel }: { channel: ChannelI }) => {
const [showMembers, setMembers] = useState(
getState().sectionToggle[MEMBERS_SIDEBAR_KEY] ?? true,
);
const [showChannels, setChannels] = useState(
getState().sectionToggle[CHANNELS_SIDEBAR_KEY] ?? true,
);
const id = channel._id;
return (
@@ -84,6 +88,22 @@ const TextChannel = observer(({ channel }: { channel: ChannelI }) => {
});
}
}}
toggleChannelSidebar={() => {
setChannels(!showChannels);
if (showChannels) {
dispatch({
type: "SECTION_TOGGLE_SET",
id: CHANNELS_SIDEBAR_KEY,
state: false,
});
} else {
dispatch({
type: "SECTION_TOGGLE_UNSET",
id: CHANNELS_SIDEBAR_KEY,
});
}
}}
/>
<ChannelMain>
<ChannelContent>