import { InfoCircle, UserPlus, UserMinus, ArrowToRight, ArrowToLeft, UserX, ShieldX, EditAlt, Edit, MessageSquareEdit, } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { SystemMessage as SystemMessageI } from "revolt-api/types/Channels"; import { Message } from "revolt.js/dist/maps/Messages"; import styled from "styled-components"; import { attachContextMenu } from "preact-context-menu"; import { TextReact } from "../../../lib/i18n"; import UserShort from "../user/UserShort"; import MessageBase, { MessageDetail, MessageInfo } from "./MessageBase"; const SystemContent = styled.div` gap: 4px; display: flex; padding: 2px 0; flex-wrap: wrap; align-items: center; flex-direction: row; `; interface Props { attachContext?: boolean; message: Message; highlight?: boolean; hideInfo?: boolean; } const iconDictionary = { user_added: UserPlus, user_remove: UserMinus, user_joined: ArrowToRight, user_left: ArrowToLeft, user_kicked: UserX, user_banned: ShieldX, channel_renamed: EditAlt, channel_description_changed: Edit, channel_icon_changed: MessageSquareEdit, text: InfoCircle, }; export const SystemMessage = observer( ({ attachContext, message, highlight, hideInfo }: Props) => { const data = message.asSystemMessage; const SystemMessageIcon = iconDictionary[data.type as SystemMessageI["type"]] ?? InfoCircle; let children; switch (data.type) { case "text": children = {data.content}; break; case "user_added": case "user_remove": children = ( , other_user: , }} /> ); break; case "user_joined": case "user_left": case "user_kicked": case "user_banned": children = ( , }} /> ); break; case "channel_renamed": children = ( , name: {data.name}, }} /> ); break; case "channel_description_changed": case "channel_icon_changed": children = ( , }} /> ); break; } return ( {!hideInfo && ( )} {children} ); }, );