sdk: decrease interval between replaceable lists and sets refetch attempts conditionally.

This commit is contained in:
fiatjaf
2025-02-04 19:27:57 -03:00
parent 0ccc1b8e9c
commit 26da7967dc
2 changed files with 13 additions and 2 deletions

View File

@@ -68,7 +68,7 @@ func fetchGenericList[I TagItemWithValue](
// but if we haven't tried fetching from the network recently we should do it
lastFetchKey := makeLastFetchKey(actualKind, pubkey)
lastFetchData, _ := sys.KVStore.Get(lastFetchKey)
if lastFetchData == nil || nostr.Now()-decodeTimestamp(lastFetchData) > 7*24*60*60 {
if lastFetchData == nil || nostr.Now()-decodeTimestamp(lastFetchData) > getLocalStoreRefreshDaysForKind(actualKind)*24*60*60 {
newV := tryFetchListFromNetwork(ctx, sys, pubkey, replaceableIndex, parseTag)
if newV != nil && newV.Event.CreatedAt > v.Event.CreatedAt {
v = *newV
@@ -140,3 +140,14 @@ func parseItemsFromEventTags[I TagItemWithValue](
}
return result
}
func getLocalStoreRefreshDaysForKind(kind int) nostr.Timestamp {
switch kind {
case 0:
return 7
case 3:
return 1
default:
return 3
}
}