import { Hash, VolumeFull } from "@styled-icons/boxicons-regular"; import { observer } from "mobx-react-lite"; import { Channel } from "revolt.js/dist/maps/Channels"; import { useContext } from "preact/hooks"; import { AppContext } from "../../context/revoltjs/RevoltClient"; import { ImageIconBase, IconBaseProps } from "./IconBase"; import fallback from "./assets/group.png"; interface Props extends IconBaseProps { isServerChannel?: boolean; } export default observer( ( props: Props & Omit< JSX.HTMLAttributes, keyof Props | "children" | "as" >, ) => { const client = useContext(AppContext); const { size, target, attachment, isServerChannel: server, animate, ...imgProps } = props; const iconURL = client.generateFileURL( target?.icon ?? attachment, { max_side: 256 }, animate, ); const isServerChannel = server || (target && (target.channel_type === "TextChannel" || target.channel_type === "VoiceChannel")); if (typeof iconURL === "undefined") { if (isServerChannel) { if (target?.channel_type === "VoiceChannel") { return ; } return ; } } // The border radius of the channel icon, if it's a server-channel it should be square (undefined). let borderRadius: string | undefined = "--border-radius-channel-icon"; if (isServerChannel) { borderRadius = undefined; } return ( // ! TODO: replace fallback with +