mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-14 11:15:02 -05:00
Persist the state of member sidebar toggle.
This commit is contained in:
parent
069a1a11ad
commit
d69b10adf5
1 changed files with 20 additions and 4 deletions
|
@ -18,6 +18,7 @@ import MemberSidebar from "../../components/navigation/right/MemberSidebar";
|
||||||
import ChannelHeader from "./ChannelHeader";
|
import ChannelHeader from "./ChannelHeader";
|
||||||
import { MessageArea } from "./messaging/MessageArea";
|
import { MessageArea } from "./messaging/MessageArea";
|
||||||
import VoiceHeader from "./voice/VoiceHeader";
|
import VoiceHeader from "./voice/VoiceHeader";
|
||||||
|
import { dispatch, getState } from "../../redux";
|
||||||
|
|
||||||
const ChannelMain = styled.div`
|
const ChannelMain = styled.div`
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
@ -73,9 +74,8 @@ export function Channel({ id }: { id: string }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MEMBERS_SIDEBAR_KEY = 'sidebar_members';
|
||||||
function TextChannel({ channel }: { channel: Channels.Channel }) {
|
function TextChannel({ channel }: { channel: Channels.Channel }) {
|
||||||
const [showMembers, setMembers] = useState(true);
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(channel.channel_type === "TextChannel" ||
|
(channel.channel_type === "TextChannel" ||
|
||||||
channel.channel_type === "Group") &&
|
channel.channel_type === "Group") &&
|
||||||
|
@ -115,13 +115,29 @@ function TextChannel({ channel }: { channel: Channels.Channel }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const [showMembers, setMembers] = useState(getState().sectionToggle[MEMBERS_SIDEBAR_KEY] ?? true);
|
||||||
|
|
||||||
let id = channel._id;
|
let id = channel._id;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ChannelHeader
|
<ChannelHeader
|
||||||
channel={channel}
|
channel={channel}
|
||||||
toggleSidebar={() => setMembers(!showMembers)}
|
toggleSidebar={() => {
|
||||||
/>
|
setMembers(!showMembers);
|
||||||
|
|
||||||
|
if (showMembers) {
|
||||||
|
dispatch({
|
||||||
|
type: 'SECTION_TOGGLE_SET',
|
||||||
|
id: MEMBERS_SIDEBAR_KEY,
|
||||||
|
state: false
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
dispatch({
|
||||||
|
type: 'SECTION_TOGGLE_UNSET',
|
||||||
|
id: MEMBERS_SIDEBAR_KEY
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}} />
|
||||||
<ChannelMain>
|
<ChannelMain>
|
||||||
<ChannelContent>
|
<ChannelContent>
|
||||||
<VoiceHeader id={id} />
|
<VoiceHeader id={id} />
|
||||||
|
|
Loading…
Reference in a new issue