Fix record permission callback thread

This commit is contained in:
Ali 2019-11-15 16:45:40 +04:00
parent e539f81f19
commit a2b69da52e

View File

@ -282,24 +282,26 @@ public final class DeviceAccess {
completion(true) completion(true)
} else { } else {
AVAudioSession.sharedInstance().requestRecordPermission({ granted in AVAudioSession.sharedInstance().requestRecordPermission({ granted in
if granted { Queue.mainQueue().async {
completion(true) if granted {
} else if let presentationData = presentationData { completion(true)
completion(false) } else if let presentationData = presentationData {
let text: String completion(false)
switch microphoneSubject { let text: String
case .audio: switch microphoneSubject {
text = presentationData.strings.AccessDenied_VoiceMicrophone case .audio:
case .video: text = presentationData.strings.AccessDenied_VoiceMicrophone
text = presentationData.strings.AccessDenied_VideoMicrophone case .video:
case .voiceCall: text = presentationData.strings.AccessDenied_VideoMicrophone
text = presentationData.strings.AccessDenied_CallMicrophone case .voiceCall:
} text = presentationData.strings.AccessDenied_CallMicrophone
present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: presentationData.theme), title: presentationData.strings.AccessDenied_Title, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_NotNow, action: {}), TextAlertAction(type: .genericAction, title: presentationData.strings.AccessDenied_Settings, action: { }
openSettings() present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: presentationData.theme), title: presentationData.strings.AccessDenied_Title, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_NotNow, action: {}), TextAlertAction(type: .genericAction, title: presentationData.strings.AccessDenied_Settings, action: {
})]), nil) openSettings()
if case .voiceCall = microphoneSubject { })]), nil)
displayNotificationFromBackground(text) if case .voiceCall = microphoneSubject {
displayNotificationFromBackground(text)
}
} }
} }
}) })