From ecda6ac414cb2cbf324bd6b55ee1b477b5ad9e13 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sat, 8 Jul 2023 20:54:31 -0300 Subject: [PATCH] client list rendering based on event kind, not code. --- utils.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/utils.go b/utils.go index ca772de..bcdd8f7 100644 --- a/utils.go +++ b/utils.go @@ -98,7 +98,7 @@ type ClientReference struct { } func generateClientList(code string, event *nostr.Event) []ClientReference { - if strings.HasPrefix(code, "nevent") || strings.HasPrefix(code, "note") { + if event.Kind == 1 || event.Kind == 6 { return []ClientReference{ {Name: "native client", URL: "nostr:" + code}, {Name: "Snort", URL: "https://Snort.social/e/" + code}, @@ -111,7 +111,7 @@ func generateClientList(code string, event *nostr.Event) []ClientReference { {Name: "Nostr.band", URL: "https://nostr.band/" + code}, {Name: "Highlighter", URL: "https://highlighter.com/a/" + code}, } - } else if strings.HasPrefix(code, "npub") || strings.HasPrefix(code, "nprofile") { + } else if event.Kind == 0 { return []ClientReference{ {Name: "Your native client", URL: "nostr:" + code}, {Name: "Nosta", URL: "https://nosta.me/" + code}, @@ -125,7 +125,7 @@ func generateClientList(code string, event *nostr.Event) []ClientReference { {Name: "Nostr.band", URL: "https://nostr.band/" + code}, {Name: "Highlighter", URL: "https://highlighter.com/p/" + event.PubKey}, } - } else if strings.HasPrefix(code, "naddr") { + } else if event.Kind == 30023 { return []ClientReference{ {Name: "Your native client", URL: "nostr:" + code}, {Name: "YakiHonne", URL: "https://yakihonne.com/article/" + code}, @@ -133,11 +133,9 @@ func generateClientList(code string, event *nostr.Event) []ClientReference { {Name: "Highlighter", URL: "https://highlighter.com/a/" + code}, {Name: "Blogstack", URL: "https://blogstack.io/" + code}, } - } else { - return []ClientReference{ - {Name: "native client", URL: "nostr:" + code}, - } } + + return nil } func mergeMaps[K comparable, V any](m1 map[K]V, m2 map[K]V) map[K]V {