@@ -12,13 +12,15 @@ import { useSnackbar } from "notistack";
1212import { useASAuthorizationStatus } from "../../hooks/useIsAuthorized" ;
1313import { getMessageFromEvent , protoBlobToText } from "../../protobuf/protobuf" ;
1414import { eventStreamEnabledAtom } from "../../state/eventStream" ;
15+ import { useUnreadEventCount } from "../../state/notifications" ;
1516import { EventMessage } from "../eventMessages/EventMessage" ;
1617import { useIsEventStreamInstalled } from "./useIsEventStreamInstalled" ;
1718
1819export const EventStream = ( ) => {
1920 const isEventStreamInstalled = useIsEventStreamInstalled ( ) ;
2021 const [ location , setLocation ] = useState < string | null > ( null ) ;
2122 const { enqueueSnackbar } = useSnackbar ( ) ;
23+ const { incrementCount } = useUnreadEventCount ( ) ;
2224 const asRole = useASAuthorizationStatus ( ) ;
2325
2426 const { data, error : streamError } = useGetEventStream ( {
@@ -69,11 +71,13 @@ export const EventStream = () => {
6971
7072 const handleWebSocketMessage = useCallback (
7173 ( event : MessageEvent ) => {
74+ console . log ( "message" ) ;
7275 if ( event . data instanceof Blob ) {
7376 protoBlobToText ( event . data )
7477 . then ( ( textData ) => {
7578 const message = getMessageFromEvent ( textData ) ;
7679 if ( message ) {
80+ incrementCount ( ) ;
7781 enqueueSnackbar ( < EventMessage message = { message } /> , {
7882 variant : "default" ,
7983 anchorOrigin : { horizontal : "right" , vertical : "bottom" } ,
@@ -97,10 +101,19 @@ export const EventStream = () => {
97101 console . warn ( "Received non-Blob WebSocket message:" , event . data ) ;
98102 }
99103 } ,
100- [ enqueueSnackbar ] ,
104+ [ enqueueSnackbar , incrementCount ] ,
101105 ) ;
102106
103- const wsUrl = eventStreamEnabled && asRole ? ( location ?. replace ( "ws" , "wss" ) ?? null ) : null ;
107+ let wsUrl = null ;
108+ if ( eventStreamEnabled && asRole && location ) {
109+ const url = new URL ( location ) ;
110+ url . protocol = "wss:" ;
111+ url . search = new URLSearchParams ( {
112+ // stream_from_timestamp: encodeURIComponent("2025-07-1T12:00:00Z"),
113+ stream_from_ordinal : "1" ,
114+ } ) . toString ( ) ;
115+ wsUrl = url . toString ( ) ;
116+ }
104117
105118 useWebSocket ( wsUrl , {
106119 onOpen : handleWebSocketOpen ,
0 commit comments