import { useContext } from "preact/hooks"; import { Hash } from "@styled-icons/feather"; import { Channels } from "revolt.js/dist/api/objects"; import { ImageIconBase, IconBaseProps } from "./IconBase"; import { AppContext } from "../../context/revoltjs/RevoltClient"; interface Props extends IconBaseProps { isServerChannel?: boolean; } const fallback = '/assets/group.png'; export default function ChannelIcon(props: Props & Omit, keyof Props>) { const { client } = useContext(AppContext); const { size, target, attachment, isServerChannel: server, animate, children, as, ...imgProps } = props; const iconURL = client.generateFileURL(target?.icon ?? attachment, { max_side: 256 }, animate); const isServerChannel = server || target?.channel_type === 'TextChannel'; if (typeof iconURL === 'undefined') { if (isServerChannel) { return ( ) } } return ( // ! fixme: replace fallback with +