diff --git a/src/app/organisms/room/AttachmentUis/VoiceMailRecorder.jsx b/src/app/organisms/room/AttachmentUis/VoiceMailRecorder.jsx index 6bdf7618..5f98ff51 100644 --- a/src/app/organisms/room/AttachmentUis/VoiceMailRecorder.jsx +++ b/src/app/organisms/room/AttachmentUis/VoiceMailRecorder.jsx @@ -17,8 +17,6 @@ let _stream; let _mediaRecorder; const audioChunks = []; -// TODO: Check if supported, check if browser allows - async function init() { if (_mediaRecorder) return; @@ -77,10 +75,17 @@ function restartRec() { function VoiceMailRecorder({ fnHowToSubmit }) { const [state, setState] = React.useState('Recording'); const [timeRecording, setTimeRecording] = React.useState('00:00'); + const [browserHasNoSupport, setBrowserHasNoSupport] = React.useState(!navigator.mediaDevices + ? 'It seems like your browser is unsupported' : null); async function initiateInitiation() { if (!_mediaRecorder) { - await init(); + await init().catch((err) => { + console.warn('Recording is disallowed', err); + setBrowserHasNoSupport('It seems like you have disallowed Cinny to record your voice ༼ つ ◕_◕ ༽つ'); + }); + + if (browserHasNoSupport) return; startOrResumeRec(); } @@ -131,7 +136,7 @@ function VoiceMailRecorder({ fnHowToSubmit }) { // fnRequestResult(stopAndSubmit); initiateInitiation(); - return ( + const ui = (
@@ -151,6 +156,10 @@ function VoiceMailRecorder({ fnHowToSubmit }) {
); + + return browserHasNoSupport + ? {browserHasNoSupport} + : ui; } VoiceMailRecorder.propTypes = { diff --git a/src/app/organisms/room/AttachmentUis/VoiceMailRecorder.scss b/src/app/organisms/room/AttachmentUis/VoiceMailRecorder.scss index 4d2abc9a..3f24e584 100644 --- a/src/app/organisms/room/AttachmentUis/VoiceMailRecorder.scss +++ b/src/app/organisms/room/AttachmentUis/VoiceMailRecorder.scss @@ -7,4 +7,8 @@ max-width: 100%; // max-width: ; } +} + +.unsupported-info { + height: 2em; } \ No newline at end of file diff --git a/src/app/organisms/room/RoomViewInput.jsx b/src/app/organisms/room/RoomViewInput.jsx index 691a895d..f37e9def 100644 --- a/src/app/organisms/room/RoomViewInput.jsx +++ b/src/app/organisms/room/RoomViewInput.jsx @@ -180,8 +180,9 @@ function RoomViewInput({ if (msgBody.trim() === '' && attachmentOrUi === null) return; sendIsTyping(false); + // TODO: Notify user about their mistake + if (typeof attachmentOrUi === 'string') return; // Attachment UI is not finished roomsInput.setMessage(roomId, msgBody); - if (typeof attachmentOrUi === 'string') console.log('input is not FINISHED'); // TODO: disallow sending if (attachmentOrUi !== null && typeof attachmentOrUi === 'object') { roomsInput.setAttachment(roomId, attachmentOrUi); }