feat: add pinned post functionality
This commit is contained in:
parent
9c554da2da
commit
d131026af9
31 changed files with 563 additions and 56 deletions
|
|
@ -332,6 +332,15 @@ export function createBookmarkDraftEvent(tags: string[][], content = ''): TDraft
|
|||
}
|
||||
}
|
||||
|
||||
export function createPinListDraftEvent(tags: string[][], content = ''): TDraftEvent {
|
||||
return {
|
||||
kind: kinds.Pinlist,
|
||||
content,
|
||||
tags,
|
||||
created_at: dayjs().unix()
|
||||
}
|
||||
}
|
||||
|
||||
export function createBlossomServerListDraftEvent(servers: string[]): TDraftEvent {
|
||||
return {
|
||||
kind: ExtendedKind.BLOSSOM_SERVER_LIST,
|
||||
|
|
|
|||
|
|
@ -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) ?? []
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue