@@ -66,13 +66,11 @@ export default function NotificationHandler({
6666 const router = useRouter ( ) ;
6767 const [ client , setClient ] = useState < Ably . Realtime | null > ( null ) ;
6868 const [ notifications , setNotifications ] = useState < UnifiedNotification [ ] > ( [ ] ) ;
69- const activeSupportTab = searchParams . get ( "activeTab" ) ;
7069
7170 const [ chatUnreadCount , setChatUnreadCount ] = useState ( 0 ) ;
7271
7372 // Ensure that mirroring doesn't overwrite sessionStorage before loading
7473 const isHydrated = useRef ( false ) ;
75- const activeSupportTabRef = useRef ( activeSupportTab ) ;
7674
7775 useEffect ( ( ) => {
7876 const realtime = getRealtimeClient ( ) ;
@@ -131,10 +129,6 @@ export default function NotificationHandler({
131129 [ apiClient , notifications ]
132130 ) ;
133131
134- useEffect ( ( ) => {
135- activeSupportTabRef . current = activeSupportTab ;
136- } , [ activeSupportTab ] ) ;
137-
138132 useEffect ( ( ) => {
139133 if ( ! user ) {
140134 sessionStorage . removeItem ( "chat_notifications" ) ;
@@ -299,7 +293,7 @@ export default function NotificationHandler({
299293 const channelId = event . channel ?. id ?? event . cid ?. split ( ":" ) [ 1 ] ;
300294 if ( ! channelId ) return ;
301295
302- if ( activeSupportTabRef . current === "Unresolved" ) return ;
296+ if ( searchParams . get ( "activeTab" ) === "Unresolved" ) return ;
303297
304298 const text = event . message ?. text ?. trim ( ) ;
305299 const channelName =
@@ -363,7 +357,7 @@ export default function NotificationHandler({
363357
364358 return ( ) => {
365359 didInterrupt = true ;
366- streamClient . off ( "message.new " , handleTicketMessage ) ;
360+ streamClient . off ( "notification.message_new " , handleTicketMessage ) ;
367361 streamClient . off ( "notification.mark_read" , handleMarkRead ) ;
368362 streamClient
369363 . disconnectUser ( )
0 commit comments