damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit e67dac13c6b8816c88c2217352cb5972fbbf5836
parent 5f2c8223bd15249ab425ec19bfefd4aa122befeb
Author: William Casarin <jb55@jb55.com>
Date:   Wed,  7 Jun 2023 06:48:23 +0200

refactor: use guard in handleProfileScan

Diffstat:
Mdamus/Views/QRCodeView.swift | 24+++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)

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