diff --git a/src/plugins/voiceMessages/index.tsx b/src/plugins/voiceMessages/index.tsx index 8365bb51a..229a1e71e 100644 --- a/src/plugins/voiceMessages/index.tsx +++ b/src/plugins/voiceMessages/index.tsx @@ -137,6 +137,11 @@ function Modal({ modalProps }: { modalProps: ModalProps; }) { const [blob, setBlob] = useState(); const [blobUrl, setBlobUrl] = useObjectUrl(); + const setAudioBlob = blob => { + setBlob(blob); + setBlobUrl(blob); + }; + useEffect(() => () => { if (blobUrl) URL.revokeObjectURL(blobUrl); @@ -182,6 +187,16 @@ function Modal({ modalProps }: { modalProps: ModalProps; }) { || blob.type.includes("codecs") && !blob.type.includes("opus") ); + const handleDrop = async (event) => { + event.preventDefault(); + const file = event.dataTransfer.files[0]; + if (file) setAudioBlob(file); + }; + + const handleDragOver = (event) => { + event.preventDefault(); + }; + return ( @@ -189,22 +204,21 @@ function Modal({ modalProps }: { modalProps: ModalProps; }) { -
+
+ { - setBlob(blob); - setBlobUrl(blob); - }} + setAudioBlob={blob => setAudioBlob(blob)} onRecordingChange={setRecording} />