feat: add pinned post functionality

This commit is contained in:
codytseng
2025-10-12 21:39:16 +08:00
parent 9c554da2da
commit d131026af9
31 changed files with 563 additions and 56 deletions

View File

@@ -1,4 +1,4 @@
import { BIG_RELAY_URLS, POLL_TYPE } from '@/constants'
import { BIG_RELAY_URLS, MAX_PINNED_NOTES, POLL_TYPE } from '@/constants'
import { TEmoji, TPollType, TRelayList, TRelaySet } from '@/types'
import { Event, kinds } from 'nostr-tools'
import { buildATag } from './draft-event'
@@ -380,3 +380,13 @@ export function getStarsFromRelayReviewEvent(event: Event): number {
}
return 0
}
export function getPinnedEventHexIdSetFromPinListEvent(event?: Event | null): Set<string> {
return new Set(
event?.tags
.filter((tag) => tag[0] === 'e')
.map((tag) => tag[1])
.reverse()
.slice(0, MAX_PINNED_NOTES) ?? []
)
}