@@ -95,29 +95,27 @@ const useWebSocket = ({
9595 // Sidebar subscriptions (existing functionality)
9696 if ( chatRooms . length > 0 && onSidebarMessage ) {
9797 sidebarSubscriptionsRef . current . forEach ( ( subscription , roomId ) => {
98- subscription . unsubscribe ( )
98+ // subscription.unsubscribe()
9999 console . log ( `🔁 Previous sidebar subscription for room ${ roomId } cleared.` )
100100 } )
101101 sidebarSubscriptionsRef . current . clear ( )
102102
103103 chatRooms . forEach ( ( room ) => {
104104 const roomUniqueId = room . uniqueId
105- if ( roomUniqueId ) {
105+ if ( roomUniqueId && ! sidebarSubscriptionsRef . current . has ( roomUniqueId ) ) {
106106 const subscription = client . subscribe ( `/topic/chat/${ roomUniqueId } ` , ( message ) => {
107107 try {
108108 const received = JSON . parse ( message . body )
109-
110109 if ( Number ( currentRoomId ) !== Number ( roomUniqueId ) ) {
111110 onSidebarMessage ( roomUniqueId , received )
112- console . log ( `📨 New message in room ${ roomUniqueId } ` )
113111 }
114112 } catch ( e ) {
115- console . error ( "📛 Failed to parse sidebar message" , e )
113+ console . error ( "Failed to parse sidebar message" , e )
116114 }
117115 } )
118116
119117 sidebarSubscriptionsRef . current . set ( roomUniqueId , subscription )
120- console . log ( `📡 Subscribed to sidebar room: ${ roomUniqueId } ` )
118+ console . log ( `Subscribed to sidebar room: ${ roomUniqueId } ` )
121119 }
122120 } )
123121 }
@@ -228,7 +226,7 @@ const useWebSocket = ({
228226 sidebarSubscriptionsRef . current . forEach ( ( subscription ) => {
229227 subscription . unsubscribe ( )
230228 } )
231- sidebarSubscriptionsRef . current . clear ( )
229+ // sidebarSubscriptionsRef.current.clear()
232230
233231 if ( client && client . active ) {
234232 client . deactivate ( ) . then ( ( ) => {
0 commit comments