Skip to content

Commit a2ef4a6

Browse files
Merge pull request #101 from Adamant-im/dev/fix_qr_crash
Fixed QR camera crash on first launch
2 parents e145821 + dfabda5 commit a2ef4a6

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

Adamant/Stories/Chats/NewChatViewController.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,19 +366,15 @@ extension NewChatViewController {
366366
case .authorized:
367367
qrReader.modalPresentationStyle = .overFullScreen
368368
present(qrReader, animated: true, completion: nil)
369-
370369
case .notDetermined:
371370
AVCaptureDevice.requestAccess(for: .video) { [weak self] (granted: Bool) in
372-
if granted, let qrReader = self?.qrReader {
373-
qrReader.modalPresentationStyle = .overFullScreen
374-
DispatchQueue.onMainAsync {
371+
DispatchQueue.onMainAsync {
372+
if granted, let qrReader = self?.qrReader {
373+
qrReader.modalPresentationStyle = .overFullScreen
375374
self?.present(qrReader, animated: true, completion: nil)
376375
}
377-
} else {
378-
return
379376
}
380377
}
381-
382378
case .restricted:
383379
let alert = UIAlertController(title: nil, message: String.adamantLocalized.login.cameraNotSupported, preferredStyle: .alert)
384380
alert.addAction(UIAlertAction(title: String.adamantLocalized.alert.ok, style: .cancel, handler: nil))

Adamant/Wallets/TransferViewControllerBase+QR.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,13 @@ extension TransferViewControllerBase {
2626

2727
case .notDetermined:
2828
AVCaptureDevice.requestAccess(for: .video) { [weak self] (granted: Bool) in
29-
if granted, let qrReader = self?.qrReader {
30-
qrReader.modalPresentationStyle = .overFullScreen
31-
DispatchQueue.onMainAsync {
29+
DispatchQueue.onMainAsync {
30+
if granted, let qrReader = self?.qrReader {
31+
qrReader.modalPresentationStyle = .overFullScreen
3232
self?.present(qrReader, animated: true, completion: nil)
3333
}
34-
} else {
35-
return
3634
}
3735
}
38-
3936
case .restricted:
4037
let alert = UIAlertController(title: nil, message: String.adamantLocalized.login.cameraNotSupported, preferredStyle: .alert)
4138
alert.addAction(UIAlertAction(title: String.adamantLocalized.alert.ok, style: .cancel, handler: nil))

0 commit comments

Comments
 (0)