sdk: a bunch of more list loaders.

This commit is contained in:
fiatjaf
2026-04-07 17:39:21 -03:00
parent d5b54a1c91
commit 82f2fbdb99
5 changed files with 175 additions and 52 deletions
+23 -1
View File
@@ -22,6 +22,17 @@ func (sys *System) FetchBookmarkList(ctx context.Context, pubkey nostr.PubKey) G
return ml
}
func (sys *System) FetchProfileBadgesList(ctx context.Context, pubkey nostr.PubKey) GenericList[string, EventRef] {
sys.profileBadgesListCacheOnce.Do(func() {
if sys.ProfileBadgesListCache == nil {
sys.ProfileBadgesListCache = cache_memory.New[GenericList[string, EventRef]](1000)
}
})
ml, _ := fetchGenericList(sys, ctx, pubkey, 10008, kind_10008, parseEventRef, sys.ProfileBadgesListCache)
return ml
}
func (sys *System) FetchPinList(ctx context.Context, pubkey nostr.PubKey) GenericList[string, EventRef] {
sys.pinListCacheOnce.Do(func() {
if sys.PinListCache == nil {
@@ -33,6 +44,17 @@ func (sys *System) FetchPinList(ctx context.Context, pubkey nostr.PubKey) Generi
return ml
}
func (sys *System) FetchGitRepositoryList(ctx context.Context, pubkey nostr.PubKey) GenericList[string, EventRef] {
sys.gitRepositoryListCacheOnce.Do(func() {
if sys.GitRepositoryListCache == nil {
sys.GitRepositoryListCache = cache_memory.New[GenericList[string, EventRef]](1000)
}
})
ml, _ := fetchGenericList(sys, ctx, pubkey, 10018, kind_10018, parseEventRef, sys.GitRepositoryListCache)
return ml
}
func parseEventRef(tag nostr.Tag) (evr EventRef, ok bool) {
if len(tag) < 2 {
return evr, false
@@ -54,5 +76,5 @@ func parseEventRef(tag nostr.Tag) (evr EventRef, ok bool) {
return evr, false
}
return evr, false
return evr, true
}