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:
parent
d51fd11180
commit
1c32fe99ce
@ -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>;
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user