@@ -8,6 +8,14 @@ import {useNotificationsStore} from "@/stores/notifications"
88import debounce from "lodash/debounce"
99import { ndk } from "@/utils/ndk"
1010import { NDKEvent , NDKSubscription } from "@nostr-dev-kit/ndk"
11+ import {
12+ KIND_REACTION ,
13+ KIND_REPOST ,
14+ KIND_TEXT_NOTE ,
15+ KIND_ZAP_RECEIPT ,
16+ KIND_HIGHLIGHT ,
17+ KIND_PICTURE_FIRST ,
18+ } from "@/utils/constants"
1119
1220let sub : NDKSubscription | undefined
1321
@@ -17,11 +25,12 @@ export const startNotificationsSubscription = debounce((myPubKey?: string) => {
1725 sub ?. stop ( )
1826
1927 const kinds : number [ ] = [
20- 7 , // reactions
21- 6 , // reposts
22- 1 , // replies
23- 9735 , // zap receipts
24- 9802 , // highlights
28+ KIND_REACTION ,
29+ KIND_REPOST ,
30+ KIND_TEXT_NOTE , // replies
31+ KIND_ZAP_RECEIPT ,
32+ KIND_HIGHLIGHT ,
33+ KIND_PICTURE_FIRST , // when tagged
2534 ]
2635
2736 const filters = {
@@ -38,7 +47,7 @@ export const startNotificationsSubscription = debounce((myPubKey?: string) => {
3847 const hideEventsByUnknownUsers = settings . content ?. hideEventsByUnknownUsers
3948
4049 sub . on ( "event" , async ( event : NDKEvent ) => {
41- if ( event . kind !== 9735 ) {
50+ if ( event . kind !== KIND_ZAP_RECEIPT ) {
4251 // allow zap notifs from self & unknown users
4352 if ( event . pubkey === myPubKey ) return
4453 if ( hideEventsByUnknownUsers && socialGraph ( ) . getFollowDistance ( event . pubkey ) > 5 )
@@ -65,24 +74,27 @@ export const startNotificationsSubscription = debounce((myPubKey?: string) => {
6574 content : event . content ,
6675 tags : event . tags ,
6776 } as IrisNotification )
68- const user = event . kind === 9735 ? getZappingUser ( event ) : event . pubkey
77+ const user = event . kind === KIND_ZAP_RECEIPT ? getZappingUser ( event ) : event . pubkey
6978 if ( ! user ) {
7079 console . warn ( "no user for event" , event )
7180 return
7281 }
7382 const existing = notification . users . get ( user )
7483 if ( ! existing || existing . time < event . created_at ) {
7584 let content : string | undefined = undefined
76- if ( event . kind === 1 ) {
85+ if ( event . kind === KIND_TEXT_NOTE ) {
7786 // Text note (reply) content
7887 content = event . content
79- } else if ( event . kind === 7 ) {
88+ } else if ( event . kind === KIND_REACTION ) {
8089 // Reaction content (emoji)
8190 content = event . content
82- } else if ( event . kind === 9735 ) {
91+ } else if ( event . kind === KIND_ZAP_RECEIPT ) {
8392 // Zap receipt - extract zap amount
8493 const zapAmount = await getZapAmount ( event )
8594 content = zapAmount > 0 ? zapAmount . toString ( ) : undefined
95+ } else if ( event . kind === KIND_PICTURE_FIRST ) {
96+ // Picture-first post content
97+ content = event . content
8698 }
8799
88100 notification . users . set ( user , {
@@ -93,9 +105,12 @@ export const startNotificationsSubscription = debounce((myPubKey?: string) => {
93105 if ( event . created_at > notification . time ) {
94106 notification . time = event . created_at
95107 // Update notification content with the latest reply/reaction
96- if ( event . kind === 1 && event . content ) {
108+ if ( event . kind === KIND_TEXT_NOTE && event . content ) {
97109 // For text notes (replies), update the notification content to show the latest reply
98110 notification . content = event . content
111+ } else if ( event . kind === KIND_PICTURE_FIRST && event . content ) {
112+ // For picture-first posts, update the notification content
113+ notification . content = event . content
99114 }
100115 }
101116
0 commit comments