sdk: automatically store replaceable events since we already check the local store for them.

This commit is contained in:
fiatjaf
2025-12-21 22:14:59 -03:00
parent dd6d3c68fb
commit 99197d8321
4 changed files with 14 additions and 1 deletions

View File

@@ -124,6 +124,8 @@ func (sys *System) FetchProfileMetadata(ctx context.Context, pubkey nostr.PubKey
newM := sys.tryFetchMetadataFromNetwork(ctx, pubkey)
if newM != nil && newM.Event.CreatedAt > pm.Event.CreatedAt {
pm = *newM
sys.Store.ReplaceEvent(*pm.Event)
}
// even if we didn't find anything register this because we tried
@@ -140,6 +142,8 @@ func (sys *System) FetchProfileMetadata(ctx context.Context, pubkey nostr.PubKey
if newM := sys.tryFetchMetadataFromNetwork(ctx, pubkey); newM != nil {
pm = *newM
sys.Store.SaveEvent(*pm.Event)
// we'll only save this if we got something which means we found at least one event
lastFetchKey := makeLastFetchKey(0, pubkey)
sys.KVStore.Set(lastFetchKey, encodeTimestamp(nostr.Now()))