refactor: use guard in handleProfileScan

This commit is contained in:
William Casarin
2023-06-07 06:48:23 +02:00
parent 5f2c8223bd
commit e67dac13c6

View File

@@ -243,18 +243,20 @@ struct QRCodeView: View {
} }
func handleProfileScan(_ prof: String) { func handleProfileScan(_ prof: String) {
if scannedCode != prof { guard scannedCode != prof else {
generator.impactOccurred() return
cameraAnimate { }
scannedCode = prof
generator.impactOccurred()
if profile(for: scannedCode) != nil { cameraAnimate {
DispatchQueue.main.asyncAfter(deadline: .now() + animationDuration) { scannedCode = prof
showProfileView = true
} if profile(for: scannedCode) != nil {
} else { DispatchQueue.main.asyncAfter(deadline: .now() + animationDuration) {
print("Profile not found") showProfileView = true
} }
} else {
print("Profile not found")
} }
} }
} }