Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 45 additions & 45 deletions packages/client/src/interface/navigation/channels/ServerSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ const CategoryBase = styled("div", {
},
});


/**
* Server channel entry
*/
Expand All @@ -325,19 +326,31 @@ function Entry(
) {
const { openModal } = useModals();

const canEditChannel = createMemo(() =>
["ManageChannel", "ManagePermissions", "ManageWebhooks"].some(
(perm) => props.channel.server?.havePermission(perm),
),
);

const canInvite = createMemo(() =>
props.channel.server?.havePermission("InviteOthers"),
);

const alertState = createMemo(() =>
!props.active && props.channel.unread && (props.channel.mentions?.size || true),
);

const attentionState = createMemo(() =>
props.active ? "selected" : props.channel.unread ? "active" : "normal",
);

return (
<a href={`/server/${props.channel.serverId}/channel/${props.channel.id}`}>
<MenuButton
use:floating={props.menuGenerator(props.channel)}
size="thin"
alert={
!props.active &&
props.channel.unread &&
(props.channel.mentions?.size || true)
}
attention={
props.active ? "selected" : props.channel.unread ? "active" : "normal"
}
alert={alertState()}
attention={attentionState()}
icon={
<>
<Switch fallback={<BiRegularHash size={20} />}>
Expand All @@ -352,42 +365,29 @@ function Entry(
}
actions={
<>
<a
use:floating={{
tooltip: {
placement: "top",
content: "Create Invite",
},
}}
onClick={(e) => {
e.preventDefault();
openModal({
type: "create_invite",
channel: props.channel,
});
}}
>
<MdPersonAdd {...iconSize("14px")} />
</a>

<a
use:floating={{
tooltip: {
placement: "top",
content: "Edit Channel",
},
}}
onClick={(e) => {
e.preventDefault();
openModal({
type: "settings",
config: "channel",
context: props.channel,
});
}}
>
<MdSettings {...iconSize("14px")} />
</a>
<Show when={canInvite()}>
<a
use:floating={{ tooltip: { placement: "top", content: "Create Invite" } }}
onClick={(e) => {
e.preventDefault();
openModal({ type: "create_invite", channel: props.channel });
}}
>
<MdPersonAdd {...iconSize("14px")} />
</a>
</Show>

<Show when={canEditChannel()}>
<a
use:floating={{ tooltip: { placement: "top", content: "Edit Channel" } }}
onClick={(e) => {
e.preventDefault();
openModal({ type: "settings", config: "channel", context: props.channel });
}}
>
<MdSettings {...iconSize("14px")} />
</a>
</Show>
</>
}
>
Expand Down Expand Up @@ -419,4 +419,4 @@ const List = styled(Column, {
width: "var(--layout-width-channel-sidebar)",
paddingRight: "var(--gap-md)",
},
});
});