Skip to content

Commit

Permalink
fix: remove ability for owners to leave server from ServerInfo modal (#…
Browse files Browse the repository at this point in the history
…1070)

Co-authored-by: Declan Chidlow <[email protected]>
  • Loading branch information
DeclanChidlow and Declan Chidlow authored Jan 29, 2025
1 parent ac2beaf commit 97a6c7d
Showing 1 changed file with 45 additions and 35 deletions.
80 changes: 45 additions & 35 deletions src/controllers/modals/components/ServerInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Text } from "preact-i18n";
import { Column, H1, IconButton, Modal, Row } from "@revoltchat/ui";

import Markdown from "../../../components/markdown/Markdown";
import { useClient } from "../../client/ClientController";
import { report } from "../../safety";
import { modalController } from "../ModalController";
import { ModalProps } from "../types";
Expand All @@ -13,6 +14,49 @@ export default function ServerInfo({
server,
...props
}: ModalProps<"server_info">) {
const client = useClient();
const isOwner = server.owner === client.user?._id;

const actions = [
{
onClick: () => {
modalController.push({
type: "server_identity",
member: server.member!,
});
return true;
},
children: "Edit Identity",
palette: "primary",
},
];

if (!isOwner) {
actions.push({
onClick: () => {
modalController.push({
type: "leave_server",
target: server,
});
return true;
},
children: "Leave Server",
palette: "error",
});
}

actions.push({
onClick: () => {
modalController.push({
type: "report",
target: server,
});
return true;
},
children: <Text id="app.special.modals.actions.report" />,
palette: "error",
});

return (
<Modal
{...props}
Expand All @@ -26,41 +70,7 @@ export default function ServerInfo({
</IconButton>
</Row>
}
actions={[
{
onClick: () => {
modalController.push({
type: "server_identity",
member: server.member!,
});
return true;
},
children: "Edit Identity",
palette: "primary",
},
{
onClick: () => {
modalController.push({
type: "leave_server",
target: server,
});
return true;
},
children: "Leave Server",
palette: "error",
},
{
onClick: () => {
modalController.push({
type: "report",
target: server,
});
return true;
},
children: <Text id="app.special.modals.actions.report" />,
palette: "error",
},
]}>
actions={actions}>
<Markdown content={server.description!} />
</Modal>
);
Expand Down

0 comments on commit 97a6c7d

Please sign in to comment.