@@ -11,7 +11,7 @@ import { clear as clearCache, find, findAll, save, watchAll } from "./util/db.ts
1111import { decode } from "nostr-tools/nip19" ;
1212import { finalizeEvent , getPublicKey } from "nostr-tools/pure" ;
1313import { Filter } from "nostr-tools/filter" ;
14- import { AggregateEvent , NoteEvent , eventToNoteEvent } from "./util/models.ts" ;
14+ import { AggregateEvent , NoteEvent , eventToNoteEvent , eventToReactionEvent , reactionKind } from "./util/models.ts" ;
1515import { SubCloser } from "nostr-tools" ;
1616
1717const ZapThreads = ( props : { [ key : string ] : string ; } ) => {
@@ -225,6 +225,12 @@ const ZapThreads = (props: { [key: string]: string; }) => {
225225 }
226226 } else if ( e . kind === 7 ) {
227227 newLikeIds . add ( e . id ) ;
228+ if ( e . content . trim ( ) ) {
229+ const reactionEvent = eventToReactionEvent ( e ) ;
230+ if ( reactionKind ( reactionEvent ) !== 0 ) { // remove this condition if you want to track all reactions
231+ save ( 'reactions' , reactionEvent ) ;
232+ }
233+ }
228234 } else if ( e . kind === 9735 ) {
229235 const invoiceTag = e . tags . find ( t => t [ 0 ] === "bolt11" ) ;
230236 invoiceTag && invoiceTag [ 1 ] && ( newZaps [ e . id ] = invoiceTag [ 1 ] ) ;
@@ -369,6 +375,9 @@ const ZapThreads = (props: { [key: string]: string; }) => {
369375 return nestedEvents ( ) . reduce ( ( acc , n ) => acc + totalChildren ( n ) , nestedEvents ( ) . length ) ;
370376 } ;
371377
378+ const reactions = watchAll ( ( ) => [ 'reactions' ] ) ;
379+ const votes = ( ) => reactions ( ) . filter ( r => reactionKind ( r ) !== 0 ) ;
380+
372381 const [ showAdvanced , setShowAdvanced ] = createSignal ( false ) ;
373382
374383 return < >
@@ -388,7 +397,7 @@ const ZapThreads = (props: { [key: string]: string; }) => {
388397 < h2 id = "ztr-title" >
389398 { commentsLength ( ) > 0 && `${ commentsLength ( ) } comment${ commentsLength ( ) == 1 ? '' : 's' } ` }
390399 </ h2 >
391- < Thread nestedEvents = { nestedEvents } articles = { articles } />
400+ < Thread nestedEvents = { nestedEvents } articles = { articles } votes = { votes } />
392401 </ > }
393402
394403 < div style = "float:right; opacity: 0.2;" onClick = { ( ) => setShowAdvanced ( ! showAdvanced ( ) ) } > { ellipsisSvg ( ) } </ div >
0 commit comments