mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-18 14:54:24 +01:00
Remove duplicates in the relays list before fetching last notes
This commit is contained in:
1
nostr.go
1
nostr.go
@@ -143,6 +143,7 @@ func getLastNotes(ctx context.Context, code string) []*nostr.Event {
|
||||
|
||||
relays = append(relays, getRelay())
|
||||
relays = append(relays, getRelay())
|
||||
relays = unique(relays)
|
||||
events := pool.SubManyEose(ctx, relays, nostr.Filters{
|
||||
{
|
||||
Kinds: []int{nostr.KindTextNote},
|
||||
|
||||
12
utils.go
12
utils.go
@@ -324,3 +324,15 @@ func mdToHTML(md string) string {
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
func unique(strSlice []string) []string {
|
||||
keys := make(map[string]bool)
|
||||
list := []string{}
|
||||
for _, entry := range strSlice {
|
||||
if _, ok := keys[entry]; !ok {
|
||||
keys[entry] = true
|
||||
list = append(list, entry)
|
||||
}
|
||||
}
|
||||
return list
|
||||
}
|
||||
Reference in New Issue
Block a user