Composer: Fix voice recording in Safari (#1440)

This commit is contained in:
Alexander Zinchuk 2021-09-16 11:27:02 +03:00
parent 7b0825877d
commit f4257d779a
2 changed files with 7 additions and 5 deletions

View File

@ -2,7 +2,7 @@ import {
useCallback, useEffect, useRef, useState,
} from '../../../../lib/teact/teact';
import { IS_IOS, IS_VOICE_RECORDING_SUPPORTED } from '../../../../util/environment';
import { IS_SAFARI, IS_VOICE_RECORDING_SUPPORTED } from '../../../../util/environment';
import * as voiceRecording from '../../../../util/voiceRecording';
import captureEscKeyListener from '../../../../util/captureEscKeyListener';
@ -17,7 +17,7 @@ export default () => {
useEffect(() => {
// Preloading worker fixes silent first record on iOS
if (IS_IOS && IS_VOICE_RECORDING_SUPPORTED) {
if (IS_SAFARI && IS_VOICE_RECORDING_SUPPORTED) {
void voiceRecording.init();
}
}, []);

View File

@ -50,9 +50,11 @@ export const IS_SINGLE_COLUMN_LAYOUT = window.innerWidth <= MOBILE_SCREEN_MAX_WI
export const IS_TABLET_COLUMN_LAYOUT = !IS_SINGLE_COLUMN_LAYOUT && (
window.innerWidth <= MIN_SCREEN_WIDTH_FOR_STATIC_LEFT_COLUMN
);
export const IS_VOICE_RECORDING_SUPPORTED = (navigator.mediaDevices && 'getUserMedia' in navigator.mediaDevices && (
window.AudioContext || (window as any).webkitAudioContext
));
export const IS_VOICE_RECORDING_SUPPORTED = Boolean(
navigator.mediaDevices && 'getUserMedia' in navigator.mediaDevices && (
window.AudioContext || (window as any).webkitAudioContext
),
);
export const IS_SMOOTH_SCROLL_SUPPORTED = 'scrollBehavior' in document.documentElement.style;
export const IS_EMOJI_SUPPORTED = PLATFORM_ENV && (IS_MAC_OS || IS_IOS);
export const IS_SERVICE_WORKER_SUPPORTED = 'serviceWorker' in navigator;