Remove ability for owners to leave server from ServerInfo modal

This commit is contained in:
Declan Chidlow 2024-12-28 16:55:42 +08:00
parent ac2beaf549
commit 9c65c87b70
2 changed files with 47 additions and 37 deletions

4
.env
View file

@ -1,5 +1,5 @@
# VITE_API_URL=https://api.revolt.chat
# VITE_API_URL=https://app.revolt.chat/api
VITE_API_URL=https://app.revolt.chat/api
# VITE_API_URL=http://local.revolt.chat:8000
VITE_API_URL=https://revolt.chat/api
# VITE_API_URL=https://revolt.chat/api
VITE_THEMES_URL=https://themes.revolt.chat

View file

@ -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";
@ -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}
@ -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>
);