import { observer } from "mobx-react-lite"; import { Channel } from "revolt.js/dist/maps/Channels"; import styled, { css } from "styled-components"; import { Text } from "preact-i18n"; import { useContext, useEffect, useState } from "preact/hooks"; import TextAreaAutoSize from "../../../lib/TextAreaAutoSize"; import { FileUploader } from "../../../context/revoltjs/FileUploads"; import { AppContext } from "../../../context/revoltjs/RevoltClient"; import Button from "../../../components/ui/Button"; import InputBox from "../../../components/ui/InputBox"; interface Props { channel: Channel; } const Row = styled.div` gap: 20px; display: flex; .name { flex-grow: 1; input { width: 100%; } } `; export default observer(({ channel }: Props) => { const client = useContext(AppContext); const [name, setName] = useState(channel.name ?? undefined); const [description, setDescription] = useState(channel.description ?? ""); useEffect(() => setName(channel.name ?? undefined), [channel.name]); useEffect( () => setDescription(channel.description ?? ""), [channel.description], ); const [changed, setChanged] = useState(false); function save() { const changes: any = {}; if (name !== channel.name) changes.name = name; if (description !== channel.description) changes.description = description; channel.edit(changes); setChanged(false); } return (
channel.edit({ icon })} previewURL={channel.generateIconURL( { max_side: 256 }, true, )} remove={() => channel.edit({ remove: "Icon" })} defaultPreview={ channel.channel_type === "Group" ? "/assets/group.png" : undefined } />

{channel.channel_type === "Group" ? ( ) : ( )}

{ setName(e.currentTarget.value); if (!changed) setChanged(true); }} />

{channel.channel_type === "Group" ? ( ) : ( )}

{ setDescription(ev.currentTarget.value); if (!changed) setChanged(true); }} />

); });