1
0
mirror of https://github.com/spacebarchat/client.git synced 2024-11-25 03:32:54 +01:00

move guild check to parent

This commit is contained in:
Puyodead1 2023-09-01 11:36:15 -04:00
parent d51fd11180
commit 1c32fe99ce
No known key found for this signature in database
GPG Key ID: BA5F91AAEF68E5CE
2 changed files with 4 additions and 7 deletions

View File

@ -16,13 +16,13 @@ const List = styled.div`
margin: 0;
`;
function EmptyChannelList() {
export function EmptyChannelList() {
return <List></List>;
}
interface Props {
channelId?: string;
guild?: Guild;
guild: Guild;
}
function ChannelList({ channelId, guild }: Props) {
@ -30,7 +30,6 @@ function ChannelList({ channelId, guild }: Props) {
const renderChannelListItem = React.useCallback(
(channel: Channel) => {
if (!guild) return null;
const permission = Permissions.getPermission(app.account!.id, guild, channel);
if (!permission.has("VIEW_CHANNEL")) return null;
@ -49,8 +48,6 @@ function ChannelList({ channelId, guild }: Props) {
[app.account, channelId, guild],
);
if (!guild) return <EmptyChannelList />;
return <List>{guild.channels.mapped.map((channel) => renderChannelListItem(channel))}</List>;
}

View File

@ -3,7 +3,7 @@ import styled from "styled-components";
import Channel from "../stores/objects/Channel";
import Guild from "../stores/objects/Guild";
import ChannelHeader from "./ChannelHeader";
import ChannelList from "./ChannelList";
import ChannelList, { EmptyChannelList } from "./ChannelList";
import Container from "./Container";
import UserPanel from "./UserPanel";
@ -30,7 +30,7 @@ function ChannelSidebar({ guild, channelId, guildId }: Props) {
<Wrapper>
{/* TODO: replace with dm search if no guild */}
<ChannelHeader guild={guild} guildId={guildId} />
<ChannelList channelId={channelId} guild={guild} />
{guild ? <ChannelList channelId={channelId} guild={guild} /> : <EmptyChannelList />}
<UserPanel />
</Wrapper>
);