import { AxiosError } from 'axios'; import clsx from 'clsx'; import React, { MutableRefObject, useEffect, useState } from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { uploadMedia } from 'soapbox/actions/media'; import { Stack } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import { normalizeAttachment } from 'soapbox/normalizers'; import { IChat, useChatActions } from 'soapbox/queries/chats'; import toast from 'soapbox/toast'; import ChatComposer from './chat-composer'; import ChatMessageList from './chat-message-list'; import type { Attachment } from 'soapbox/types/entities'; const fileKeyGen = (): number => Math.floor((Math.random() * 0x10000)); const messages = defineMessages({ failedToSend: { id: 'chat.failed_to_send', defaultMessage: 'Message failed to send.' }, uploadErrorLimit: { id: 'upload_error.limit', defaultMessage: 'File upload limit exceeded.' }, }); interface ChatInterface { chat: IChat, inputRef?: MutableRefObject, className?: string, } /** * Clears the value of the input while dispatching the `onChange` function * which allows the