flow: safety, ui, sizing

This commit is contained in:
cha0s 2020-07-18 08:11:49 -05:00
parent 241482ca7d
commit 3282372ef6
4 changed files with 14 additions and 13 deletions

View File

@ -11,7 +11,7 @@
}
.left.open {
width: 18em;
width: 25em;
}
.bar__brandItem .muted {

View File

@ -4,6 +4,7 @@ import classnames from 'classnames';
import React, {useState} from 'react';
import {useSelector} from 'react-redux';
import {channelUsersSelector} from '~/common/state/chat';
import {blockedSelector} from '~/common/state/user';
import useBreakpoints from '~/client/hooks/useBreakpoints';
@ -18,16 +19,16 @@ export default function ChatRight() {
const [active, setActive] = useState(0);
const [isOpen, setIsOpen] = useState(false);
const channel = useChannel();
const ids = useSelector((state) => blockedSelector(state, channel));
const blockedIds = useSelector((state) => blockedSelector(state, channel));
const channelUsers = useSelector((state) => channelUsersSelector(state, channel));
const toggleOpen = () => setIsOpen(!isOpen);
const showsAsOpen = isOpen || desktop || !tablet;
const buttons = [
{
icon: '🙃',
label: 'Present',
},
]
.concat(ids.length > 0 ? [{icon: '☢️', label: 'Blocked'}] : []);
const buttons = []
.concat(channelUsers.length > 0 ? [{icon: '🙃', label: 'Present'}] : [])
.concat(blockedIds.length > 0 ? [{icon: '☢️', label: 'Blocked'}] : []);
if (0 === buttons.length) {
return null;
}
return (
<div
className={classnames('right', 'flexed', showsAsOpen ? 'open' : 'closed')}
@ -42,8 +43,8 @@ export default function ChatRight() {
setActive(active);
}}
/>
{0 === active && <ChatRightUsers />}
{1 === active && ids.length > 0 && <ChatRightBlocked ids={ids} />}
{0 === active && channelUsers.length > 0 && <ChatRightUsers />}
{1 === active && blockedIds.length > 0 && <ChatRightBlocked blockedIds={blockedIds} />}
</div>
);
}

View File

@ -11,7 +11,7 @@
}
.right.open {
width: 18em;
width: 25em;
}
.right__buttons {

View File

@ -15,7 +15,7 @@ export const channelSelector = createSelector(
export const channelUsersSelector = createSelector(
[channelSelector],
({users}) => users,
(channel) => (channel ? channel.users : []),
);
export const messagesSelector = (state) => state.chat.messages;