Verified Commit a8419b97 authored by insert's avatar insert

Fix sidebar actions.

parent 11bd6247
Pipeline #280 passed with stage
in 3 minutes and 3 seconds
......@@ -27,12 +27,14 @@ export const ChatContext = createContext<{
setPage: (page: Page) => void,
channel?: string,
setChannel: (channel: string) => void,
setDrawer: (open: boolean) => void
setDrawer: (open: boolean) => void,
switch: (page: Page, channel?: string) => void
}>({
page: Page.HOME,
setPage: () => {},
setChannel: () => {},
setDrawer: () => {}
setDrawer: () => {},
switch: () => {}
});
const Chat = memo(() => {
......@@ -43,7 +45,12 @@ const Chat = memo(() => {
let states = {
page, setPage,
channel, setChannel,
setDrawer
setDrawer,
switch: (page: Page, channel?: string) => {
setPage(page);
setChannel(channel);
setDrawer(false);
}
} as any;
let body;
......
import React, { useState, Fragment, memo } from 'react';
import React, { useState, Fragment, memo, useContext } from 'react';
import styles from './Home.module.scss';
import common from './common.module.scss';
......@@ -8,8 +8,11 @@ import { scrollable } from '../../../../components/util/Scrollbar';
import { Instance } from '../../../../internal/Client';
import { DMChannel, GroupChannel, Channel } from 'riotchat.js/dist/internal/Channel';
import { ChannelEntry } from './home/Channel';
import { ChatContext, Page } from '../../../Chat';
export const HomeSidebar = memo(() => {
let chat = useContext(ChatContext);
function Channels(props: { array: Channel[], collapse: boolean }) {
return (
<div className={styles.directMessages}>
......@@ -50,9 +53,9 @@ export const HomeSidebar = memo(() => {
return (
<div className={classes}>
<div className={styles.tabs}>
<div className={styles.tab}><Icon icon="homeSolid"/>Feed</div>
<div className={styles.tab}><Icon icon="newsSolid"/>News</div>
<div className={styles.tab}><Icon icon="userDetailSolid"/>Friends</div>
<div onClick={e => chat.switch(Page.HOME)} className={styles.tab}><Icon icon="homeSolid"/>Home</div>
<div onClick={e => chat.switch(Page.FEED)} className={styles.tab}><Icon icon="newsSolid"/>Feed</div>
<div onClick={e => chat.switch(Page.FRIENDS)} className={styles.tab}><Icon icon="userDetailSolid"/>Friends</div>
</div>
<Section title="Direct Messages" icon="userPlusSolid" type={DMChannel} />
<Section title="Group Messages" icon="plusRegular" type={GroupChannel} />
......
......@@ -19,18 +19,12 @@ export const ChannelEntry = memo((props: ChannelProps) => {
name = user.username;
status = user.status;
click = () => {
chat.setPage(Page.DM);
chat.setChannel(props.channel.id);
};
click = () => chat.switch(Page.DM, props.channel.id);
} else {
iconURL = 'GROUP ICON';
name = props.channel.group.displayTitle;
click = () => {
chat.setPage(Page.GROUP);
chat.setChannel(props.channel.id);
};
click = () => chat.switch(Page.GROUP, props.channel.id);
}
return (
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment