Fix microphone permission checking for audio recording
See [#5580][0]. [0]: https://github.com/signalapp/Signal-Desktop/pull/5580
This commit is contained in:
parent
1dc353f089
commit
79b3b6408e
8 changed files with 69 additions and 43 deletions
|
@ -97,12 +97,19 @@ export const AudioCapture = ({
|
|||
const startRecordingShortcut = useStartRecordingShortcut(startRecording);
|
||||
useKeyboardShortcuts(startRecordingShortcut);
|
||||
|
||||
const closeToast = useCallback(() => {
|
||||
setToastType(undefined);
|
||||
}, []);
|
||||
|
||||
// Update timestamp regularly, then timeout if recording goes over five minutes
|
||||
useEffect(() => {
|
||||
if (!isRecording) {
|
||||
return;
|
||||
}
|
||||
|
||||
setDurationText(START_DURATION_TEXT);
|
||||
setToastType(ToastType.VoiceNoteLimit);
|
||||
|
||||
const startTime = Date.now();
|
||||
const interval = setInterval(() => {
|
||||
const duration = moment.duration(Date.now() - startTime, 'ms');
|
||||
|
@ -120,8 +127,15 @@ export const AudioCapture = ({
|
|||
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
closeToast();
|
||||
};
|
||||
}, [completeRecording, errorRecording, isRecording, setDurationText]);
|
||||
}, [
|
||||
closeToast,
|
||||
completeRecording,
|
||||
errorRecording,
|
||||
isRecording,
|
||||
setDurationText,
|
||||
]);
|
||||
|
||||
const clickCancel = useCallback(() => {
|
||||
cancelRecording();
|
||||
|
@ -131,10 +145,6 @@ export const AudioCapture = ({
|
|||
completeRecording(conversationId, onSendAudioRecording);
|
||||
}, [conversationId, completeRecording, onSendAudioRecording]);
|
||||
|
||||
const closeToast = useCallback(() => {
|
||||
setToastType(undefined);
|
||||
}, []);
|
||||
|
||||
let toastElement: JSX.Element | undefined;
|
||||
if (toastType === ToastType.VoiceNoteLimit) {
|
||||
toastElement = <ToastVoiceNoteLimit i18n={i18n} onClose={closeToast} />;
|
||||
|
@ -226,8 +236,6 @@ export const AudioCapture = ({
|
|||
if (draftAttachments.length) {
|
||||
setToastType(ToastType.VoiceNoteMustBeOnlyAttachment);
|
||||
} else {
|
||||
setDurationText(START_DURATION_TEXT);
|
||||
setToastType(ToastType.VoiceNoteLimit);
|
||||
startRecording();
|
||||
}
|
||||
}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue