import { For, Match, Switch } from "solid-js"; import { Trans } from "@lingui-solid/solid/macro"; import type { Channel } from "stoat.js"; import { styled } from "styled-system/jsx"; import { useClient, useUser } from "@revolt/client"; import { Markdown } from "@revolt/markdown"; import { userInformation } from "@revolt/markdown/users"; import { useState } from "@revolt/state"; import type { UnsentMessage } from "@revolt/state/stores/Draft"; import { Avatar, MessageContainer, MessageReply, SizedContent, Text, Username, } from "@revolt/ui"; import { DraftMessageContextMenu } from "../../../menus/DraftMessageContextMenu"; interface Props { draft: UnsentMessage; channel: Channel; tail?: boolean; } /** * Unsent message preview */ export function DraftMessage(props: Props) { const user = useUser(); const state = useState(); const client = useClient(); const userInfo = () => userInformation(user(), props.channel.server?.member); return ( } timestamp={ props.draft.status === "sending" ? ( Sending... ) : props.draft.status === "failed" ? ( Failed to send ) : ( Unsent message ) } sendStatus={props.draft.status === "sending" ? "sending" : "failed"} username={} header={ {(reply) => ( )} } contextMenu={() => ( )} compact={state.settings.getValue("appearance:compact_mode")} > {(id) => { const file = state.draft.getFile(id); return ( <> Uploading file `{file.file.name}`...{" "} {(file.uploadProgress[0]() * 100).toFixed()}% ); }} ); } /** * Break all text and prevent overflow from math blocks */ const BreakText = styled("div", { base: { wordBreak: "break-word", "& .math": { overflowX: "auto", overflowY: "hidden", maxHeight: "100vh", }, }, });