fix: replies

This commit is contained in:
codytseng
2025-05-15 23:38:22 +08:00
parent a6c2decfe3
commit 304bbe4f01
13 changed files with 178 additions and 120 deletions

View File

@@ -1,12 +1,11 @@
import client from '@/services/client.service'
import { Event, nip19 } from 'nostr-tools'
import { getSharableEventId } from './event'
import { generateEventId } from './tag'
export const toHome = () => '/'
export const toNote = (eventOrId: Pick<Event, 'id' | 'pubkey'> | string) => {
if (typeof eventOrId === 'string') return `/notes/${eventOrId}`
const relay = client.getEventHint(eventOrId.id)
const nevent = nip19.neventEncode({ id: eventOrId.id, author: eventOrId.pubkey, relays: [relay] })
const nevent = generateEventId(eventOrId)
return `/notes/${nevent}`
}
export const toNoteList = ({ hashtag, search }: { hashtag?: string; search?: string }) => {

View File

@@ -1,6 +1,7 @@
import client from '@/services/client.service'
import { TImageInfo } from '@/types'
import { isBlurhashValid } from 'blurhash'
import { nip19 } from 'nostr-tools'
import { Event, nip19 } from 'nostr-tools'
import { isValidPubkey } from './pubkey'
export function tagNameEquals(tagName: string) {
@@ -28,6 +29,11 @@ export function generateEventIdFromETag(tag: string[]) {
}
}
export function generateEventId(event: Pick<Event, 'id' | 'pubkey'>) {
const relay = client.getEventHint(event.id)
return nip19.neventEncode({ id: event.id, author: event.pubkey, relays: [relay] })
}
export function extractImageInfoFromTag(tag: string[]): TImageInfo | null {
if (tag[0] !== 'imeta') return null
const urlItem = tag.find((item) => item.startsWith('url '))