From ffe27848731ce9a2dffe7c7ef0524207ef7b58ea Mon Sep 17 00:00:00 2001 From: William Casarin Date: Sun, 30 Oct 2022 23:20:17 -0700 Subject: [PATCH] lightning_uri: small cleanup Signed-off-by: William Casarin --- damus/Nostr/Nostr.swift | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/damus/Nostr/Nostr.swift b/damus/Nostr/Nostr.swift index fa95ca1..cc1289c 100644 --- a/damus/Nostr/Nostr.swift +++ b/damus/Nostr/Nostr.swift @@ -18,15 +18,7 @@ struct Profile: Decodable { let lud16: String? var lightning_uri: URL? { - if let url = (self.lud06.flatMap { URL(string: "lightning:" + $0) }) { - return url - } - - if let url = (self.lud16.flatMap { URL(string: "lightning:" + $0) }) { - return url - } - - return nil + return make_ln_url(self.lud06) ?? make_ln_url(self.lud16) } static func displayName(profile: Profile?, pubkey: String) -> String { @@ -34,9 +26,8 @@ struct Profile: Decodable { } } -enum NostrTag { - case other_event(OtherEvent) - case key_event(KeyEvent) +func make_ln_url(_ str: String?) -> URL? { + return str.flatMap { URL(string: "lightning:" + $0) } } struct NostrSubscription {