Bugfix in qr code scanner for perm links

This commit is contained in:
Arnfried Griesert
2023-03-09 11:28:46 +01:00
parent f7c3aff116
commit bb90977f05
+21 -12
View File
@@ -52,23 +52,32 @@ struct PermalinkQRCodeScanner: View {
Alert(
title: Text(BWIL10n.roomRecentsScanFailedTitle),
message: Text(BWIL10n.roomRecentsScanFailedMessage),
dismissButton: .default(Text(VectorL10n.ok)))
dismissButton: .default(Text(VectorL10n.ok)) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
presentationMode.wrappedValue.dismiss()
}
}
)
}
}
.onChange(of: scanCompleted) { newValue in
if newValue {
if !BWIBuildSettings.shared.clientPermalinkBaseUrl.isEmpty && qrCode.hasPrefix(BWIBuildSettings.shared.clientPermalinkBaseUrl) {
presentationMode.wrappedValue.dismiss()
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
if let url = URL(string: qrCode) {
UIApplication.shared.open(url)
}
}
} else {
showInvalidCodeAlert = true
}
checkQRCode()
}
}
}
private func checkQRCode() {
if !BWIBuildSettings.shared.clientPermalinkBaseUrl.isEmpty && qrCode.hasPrefix(BWIBuildSettings.shared.clientPermalinkBaseUrl) {
presentationMode.wrappedValue.dismiss()
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
if let url = URL(string: qrCode) {
UIApplication.shared.open(url)
}
}
} else {
showInvalidCodeAlert = true
}
}
}