diff --git a/src/app/organisms/room/RoomViewInput.jsx b/src/app/organisms/room/RoomViewInput.jsx index b6302535..d3bf2b44 100644 --- a/src/app/organisms/room/RoomViewInput.jsx +++ b/src/app/organisms/room/RoomViewInput.jsx @@ -37,7 +37,7 @@ let cmdCursorPos = null; function RoomViewInput({ roomId, roomTimeline, viewEvent, }) { - const [attachment, setAttachment] = useState(null); + const [attachmentOrUi, setAttachmentOrUi] = useState(null); const [isMarkdown, setIsMarkdown] = useState(settings.isMarkdown); const [replyTo, setReplyTo] = useState(null); @@ -84,7 +84,7 @@ function RoomViewInput({ } function clearAttachment(myRoomId) { if (roomId !== myRoomId) return; - setAttachment(null); + setAttachmentOrUi(null); inputBaseRef.current.style.backgroundImage = 'unset'; uploadInputRef.current.value = null; } @@ -152,7 +152,7 @@ function RoomViewInput({ if (textAreaRef?.current !== null) { isTyping = false; textAreaRef.current.value = roomsInput.getMessage(roomId); - setAttachment(roomsInput.getAttachment(roomId)); + setAttachmentOrUi(roomsInput.getAttachment(roomId)); setReplyTo(roomsInput.getReplyTo(roomId)); } return () => { @@ -179,12 +179,13 @@ function RoomViewInput({ requestAnimationFrame(() => deactivateCmdAndEmit()); const msgBody = textAreaRef.current.value; if (roomsInput.isSending(roomId)) return; - if (msgBody.trim() === '' && attachment === null) return; + if (msgBody.trim() === '' && attachmentOrUi === null) return; sendIsTyping(false); roomsInput.setMessage(roomId, msgBody); - if (attachment !== null) { - roomsInput.setAttachment(roomId, attachment); + if (typeof attachmentOrUi === 'string') console.log('input is not FINISHED'); // TODO: remove + if (attachmentOrUi !== null && typeof attachmentOrUi === 'object') { + roomsInput.setAttachment(roomId, attachmentOrUi); } textAreaRef.current.disabled = true; textAreaRef.current.style.cursor = 'not-allowed'; @@ -271,8 +272,8 @@ function RoomViewInput({ const item = e.clipboardData.items[i]; if (item.type.indexOf('image') !== -1) { const image = item.getAsFile(); - if (attachment === null) { - setAttachment(image); + if (attachmentOrUi === null) { + setAttachmentOrUi(image); if (image !== null) { roomsInput.setAttachment(roomId, image); return; @@ -291,7 +292,7 @@ function RoomViewInput({ function uploadFileChange(e) { const file = e.target.files.item(0); - setAttachment(file); + setAttachmentOrUi(file); if (file !== null) roomsInput.setAttachment(roomId, file); } @@ -318,7 +319,7 @@ function RoomViewInput({ const audioFile = new File([audioBlob], 'voicemail.webm', opts); - setAttachment(audioFile); + setAttachmentOrUi(audioFile); roomsInput.setAttachment(roomId, audioFile); }); @@ -357,11 +358,11 @@ function RoomViewInput({ } return ( <> -