feat: mute
This commit is contained in:
@@ -202,6 +202,15 @@ export function createFollowListDraftEvent(tags: string[][], content?: string):
|
||||
}
|
||||
}
|
||||
|
||||
export function createMuteListDraftEvent(tags: string[][], content?: string): TDraftEvent {
|
||||
return {
|
||||
kind: kinds.Mutelist,
|
||||
content: content ?? '',
|
||||
created_at: dayjs().unix(),
|
||||
tags
|
||||
}
|
||||
}
|
||||
|
||||
export function createProfileDraftEvent(content: string, tags: string[][] = []): TDraftEvent {
|
||||
return {
|
||||
kind: kinds.Metadata,
|
||||
|
||||
@@ -67,18 +67,6 @@ export function getUsingClient(event: Event) {
|
||||
return event.tags.find(tagNameEquals('client'))?.[1]
|
||||
}
|
||||
|
||||
export function getFollowingsFromFollowListEvent(event: Event) {
|
||||
return Array.from(
|
||||
new Set(
|
||||
event.tags
|
||||
.filter(tagNameEquals('p'))
|
||||
.map(([, pubkey]) => pubkey)
|
||||
.filter(Boolean)
|
||||
.reverse()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
export function getRelayListFromRelayListEvent(event?: Event) {
|
||||
if (!event) {
|
||||
return { write: BIG_RELAY_URLS, read: BIG_RELAY_URLS, originalRelays: [] }
|
||||
@@ -292,3 +280,7 @@ export function extractEmbeddedNotesFromContent(content: string) {
|
||||
|
||||
return { embeddedNotes, contentWithoutEmbeddedNotes: c }
|
||||
}
|
||||
|
||||
export function getLatestEvent(events: Event[]) {
|
||||
return events.sort((a, b) => b.created_at - a.created_at)[0]
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ export const toRelaySettings = (tag?: 'mailbox' | 'relay-sets') => {
|
||||
export const toSettings = () => '/settings'
|
||||
export const toProfileEditor = () => '/profile-editor'
|
||||
export const toRelay = (url: string) => `/relays/${encodeURIComponent(url)}`
|
||||
export const toMuteList = () => '/mutes'
|
||||
|
||||
export const toNoStrudelProfile = (id: string) => `https://nostrudel.ninja/#/u/${id}`
|
||||
export const toNoStrudelNote = (id: string) => `https://nostrudel.ninja/#/n/${id}`
|
||||
|
||||
@@ -42,3 +42,23 @@ export function extractImageInfoFromTag(tag: string[]): TImageInfo | null {
|
||||
}
|
||||
return image
|
||||
}
|
||||
|
||||
export function extractPubkeysFromEventTags(tags: string[][]) {
|
||||
return Array.from(
|
||||
new Set(
|
||||
tags
|
||||
.filter(tagNameEquals('p'))
|
||||
.map(([, pubkey]) => pubkey)
|
||||
.filter(Boolean)
|
||||
.reverse()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
export function isSameTag(tag1: string[], tag2: string[]) {
|
||||
if (tag1.length !== tag2.length) return false
|
||||
for (let i = 0; i < tag1.length; i++) {
|
||||
if (tag1[i] !== tag2[i]) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user