11import * as React from "react" ;
22import {
33 EMPTY_SET ,
4+ isHomeActivityEvent ,
45 useLiveChannelUpdates ,
56 type UseLiveChannelUpdatesOptions ,
67} from "@/features/channels/useLiveChannelUpdates" ;
@@ -52,7 +53,6 @@ export {
5253 readActivityFromStorage ,
5354 writeActivityToStorage ,
5455} from "@/features/channels/threadActivityStorage" ;
55-
5656type UseUnreadChannelsOptions = UseLiveChannelUpdatesOptions & {
5757 pubkey ?: string ;
5858 relayClient ?: RelayClient ;
@@ -239,8 +239,8 @@ export function useUnreadChannels(
239239 const mutedChannelIdsRef = React . useRef < ReadonlySet < string > > ( new Set ( ) ) ;
240240 mutedChannelIdsRef . current = mutedChannelIdsOption ?? new Set ( ) ;
241241
242- // Thread reply events that triggered notifications — surfaced in the Home
243- // activity feed as synthetic FeedItems.
242+ // Thread replies and external DM messages that triggered notifications —
243+ // surfaced in the Home activity feed as synthetic FeedItems.
244244 const threadActivityRef = React . useRef < ThreadActivityItem [ ] > ( [ ] ) ;
245245 // Tracks the (pubkey:relayUrl) scope currently loaded into threadActivityRef.
246246 // Writers guard against this before merging so in-flight writes from a prior
@@ -477,7 +477,7 @@ export function useUnreadChannels(
477477 [ normalizedPubkey ] ,
478478 ) ;
479479
480- const handleThreadReplyNotification = React . useCallback (
480+ const handleHomeActivity = React . useCallback (
481481 ( channelId : string , event : RelayEvent ) => {
482482 // Guard: don't merge into a ref whose scope has drifted from the current
483483 // identity. Also reject an empty scope — activityScopeKey() returns ""
@@ -551,7 +551,7 @@ export function useUnreadChannels(
551551 useLiveChannelUpdates ( channels , activeChannelId , {
552552 ...liveUpdateOptions ,
553553 onChannelMessage : handleChannelMessage ,
554- onThreadReplyNotification : handleThreadReplyNotification ,
554+ onHomeActivity : handleHomeActivity ,
555555 onSelfChannelMessage : handleSelfChannelMessage ,
556556 participatedRootIds : participatedRootIdsRef . current ,
557557 followedRootIds : liveUpdateOptions . followedRootIds ,
@@ -662,7 +662,7 @@ export function useUnreadChannels(
662662 // applying the notification filter to both.
663663 let maxExternal = 0 ;
664664 const unreadEvents : ObservedUnreadEvent [ ] = [ ] ;
665- const threadReplies : ThreadActivityItem [ ] = [ ] ;
665+ const activityItems : ThreadActivityItem [ ] = [ ] ;
666666 const chType = channel ?. channelType ;
667667 const chName = channel ?. name ?? "" ;
668668 for ( const event of events ) {
@@ -707,8 +707,8 @@ export function useUnreadChannels(
707707 isThreadedReply,
708708 } ) ,
709709 ) ;
710- if ( isThreadedReply ) {
711- threadReplies . push ( {
710+ if ( isHomeActivityEvent ( chType === "dm" , isThreadedReply ) ) {
711+ activityItems . push ( {
712712 id : event . id ,
713713 kind : event . kind ,
714714 pubkey : event . pubkey ,
@@ -726,7 +726,7 @@ export function useUnreadChannels(
726726 ok : true ,
727727 maxExternal,
728728 unreadEvents,
729- threadReplies,
729+ threadReplies : activityItems ,
730730 } ;
731731 } catch {
732732 // Transient relay failure for this channel — release the claim
0 commit comments