From 9c65c87b7040ba6628816ec24a2e23799b301213 Mon Sep 17 00:00:00 2001 From: Declan Chidlow Date: Sat, 28 Dec 2024 16:55:42 +0800 Subject: [PATCH] Remove ability for owners to leave server from ServerInfo modal --- .env | 4 +- .../modals/components/ServerInfo.tsx | 80 +++++++++++-------- 2 files changed, 47 insertions(+), 37 deletions(-) diff --git a/.env b/.env index c13d0719..c8b232c2 100644 --- a/.env +++ b/.env @@ -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 diff --git a/src/controllers/modals/components/ServerInfo.tsx b/src/controllers/modals/components/ServerInfo.tsx index 23598af0..ffda6807 100644 --- a/src/controllers/modals/components/ServerInfo.tsx +++ b/src/controllers/modals/components/ServerInfo.tsx @@ -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: , + palette: "error", + }); + return ( } - 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: , - palette: "error", - }, - ]}> + actions={actions}> );