Browse Source

fix: 🐛

imwald
codytseng 11 months ago
parent
commit
f5f34e31fa
  1. 3
      src/lib/event.ts
  2. 8
      src/providers/NoteStatsProvider.tsx

3
src/lib/event.ts

@ -419,6 +419,7 @@ export function extractZapInfoFromReceipt(receiptEvent: Event) { @@ -419,6 +419,7 @@ export function extractZapInfoFromReceipt(receiptEvent: Event) {
let senderPubkey: string | undefined
let recipientPubkey: string | undefined
let originalEventId: string | undefined
let eventId: string | undefined
let invoice: string | undefined
let amount: number | undefined
@ -436,6 +437,7 @@ export function extractZapInfoFromReceipt(receiptEvent: Event) { @@ -436,6 +437,7 @@ export function extractZapInfoFromReceipt(receiptEvent: Event) {
recipientPubkey = tagValue
break
case 'e':
originalEventId = tag[1]
eventId = generateEventIdFromETag(tag)
break
case 'bolt11':
@ -467,6 +469,7 @@ export function extractZapInfoFromReceipt(receiptEvent: Event) { @@ -467,6 +469,7 @@ export function extractZapInfoFromReceipt(receiptEvent: Event) {
senderPubkey,
recipientPubkey,
eventId,
originalEventId,
invoice,
amount,
comment,

8
src/providers/NoteStatsProvider.tsx

@ -170,11 +170,11 @@ export function NoteStatsProvider({ children }: { children: React.ReactNode }) { @@ -170,11 +170,11 @@ export function NoteStatsProvider({ children }: { children: React.ReactNode }) {
if (evt.kind === kinds.Zap) {
const info = extractZapInfoFromReceipt(evt)
if (!info) return
const { eventId, senderPubkey, invoice, amount, comment } = info
if (!eventId || !senderPubkey) return
const newZaps = newZapsMap.get(eventId) || []
const { originalEventId, senderPubkey, invoice, amount, comment } = info
if (!originalEventId || !senderPubkey) return
const newZaps = newZapsMap.get(originalEventId) || []
newZaps.push({ pr: invoice, pubkey: senderPubkey, amount, comment })
newZapsMap.set(eventId, newZaps)
newZapsMap.set(originalEventId, newZaps)
return
}
})

Loading…
Cancel
Save