2021-06-20 12:31:53 -04:00
|
|
|
import styled from "styled-components";
|
2021-06-21 16:11:53 -04:00
|
|
|
import { useState } from "preact/hooks";
|
|
|
|
import ChannelHeader from "./ChannelHeader";
|
2021-06-20 12:31:53 -04:00
|
|
|
import { useParams } from "react-router-dom";
|
|
|
|
import { MessageArea } from "./messaging/MessageArea";
|
2021-06-21 16:11:53 -04:00
|
|
|
// import { useRenderState } from "../../lib/renderer/Singleton";
|
|
|
|
import { isTouchscreenDevice } from "../../lib/isTouchscreenDevice";
|
2021-06-20 15:30:42 -04:00
|
|
|
import MessageBox from "../../components/common/messaging/MessageBox";
|
2021-06-21 16:11:53 -04:00
|
|
|
import { useChannel, useForceUpdate } from "../../context/revoltjs/hooks";
|
|
|
|
import MemberSidebar from "../../components/navigation/right/MemberSidebar";
|
|
|
|
import JumpToBottom from "../../components/common/messaging/bars/JumpToBottom";
|
|
|
|
import TypingIndicator from "../../components/common/messaging/bars/TypingIndicator";
|
2021-06-20 12:31:53 -04:00
|
|
|
|
|
|
|
const ChannelMain = styled.div`
|
|
|
|
flex-grow: 1;
|
|
|
|
display: flex;
|
|
|
|
min-height: 0;
|
|
|
|
overflow: hidden;
|
|
|
|
flex-direction: row;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const ChannelContent = styled.div`
|
|
|
|
flex-grow: 1;
|
|
|
|
display: flex;
|
|
|
|
overflow: hidden;
|
|
|
|
flex-direction: column;
|
|
|
|
`;
|
|
|
|
|
2021-06-21 16:11:53 -04:00
|
|
|
export function Channel({ id }: { id: string }) {
|
2021-06-20 12:31:53 -04:00
|
|
|
const ctx = useForceUpdate();
|
|
|
|
const channel = useChannel(id, ctx);
|
|
|
|
|
|
|
|
if (!channel) return null;
|
2021-06-21 16:11:53 -04:00
|
|
|
const [ showMembers, setMembers ] = useState(true);
|
2021-06-20 12:31:53 -04:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2021-06-21 16:11:53 -04:00
|
|
|
<ChannelHeader channel={channel} toggleSidebar={() => setMembers(!showMembers)} />
|
2021-06-20 12:31:53 -04:00
|
|
|
<ChannelMain>
|
|
|
|
<ChannelContent>
|
|
|
|
<MessageArea id={id} />
|
2021-06-21 16:11:53 -04:00
|
|
|
<TypingIndicator id={channel._id} />
|
|
|
|
<JumpToBottom id={id} />
|
2021-06-20 15:30:42 -04:00
|
|
|
<MessageBox channel={channel} />
|
2021-06-20 12:31:53 -04:00
|
|
|
</ChannelContent>
|
2021-06-21 16:11:53 -04:00
|
|
|
{ !isTouchscreenDevice && showMembers && <MemberSidebar channel={channel} /> }
|
2021-06-20 12:31:53 -04:00
|
|
|
</ChannelMain>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
2021-06-21 16:11:53 -04:00
|
|
|
|
|
|
|
export default function() {
|
|
|
|
const { channel } = useParams<{ channel: string }>();
|
|
|
|
return <Channel id={channel} key={channel} />;
|
|
|
|
}
|