@@ -17,7 +17,7 @@ import { logError } from '@codesandbox/common/lib/utils/analytics';
1717export const onJoin : Operator < LiveMessage < {
1818 status : 'connected' ;
1919 live_user_id : string ;
20- } > > = mutate ( ( { effects, state } , { data } ) => {
20+ } > > = mutate ( ( { effects, actions , state } , { data } ) => {
2121 state . live . liveUserId = data . live_user_id ;
2222
2323 // Show message to confirm that you've joined a live session if you're not the owner
@@ -26,9 +26,15 @@ export const onJoin: Operator<LiveMessage<{
2626 }
2727
2828 if ( state . live . reconnecting ) {
29+ // We reconnected!
2930 effects . live . getAllClients ( ) . forEach ( client => {
3031 client . serverReconnect ( ) ;
3132 } ) ;
33+
34+ if ( state . live . roomInfo ) {
35+ // Clear all user selections
36+ actions . live . internal . clearUserSelections ( null ) ;
37+ }
3238 }
3339
3440 state . live . reconnecting = false ;
@@ -129,11 +135,6 @@ export const onUserLeft: Operator<LiveMessage<{
129135 return ;
130136 }
131137
132- if ( state . live . followingUserId === data . left_user_id ) {
133- // Unfollow user if they are the one who left
134- actions . live . onStopFollow ( ) ;
135- }
136-
137138 if ( ! state . live . notificationsHidden ) {
138139 const { users } = state . live . roomInfo ;
139140 const user = users ? users . find ( u => u . id === data . left_user_id ) : null ;
@@ -150,7 +151,7 @@ export const onUserLeft: Operator<LiveMessage<{
150151 }
151152 }
152153
153- actions . live . internal . clearUserSelections ( data . left_user_id ) ;
154+ actions . live . onUserLeft ( { liveUserId : data . left_user_id } ) ;
154155
155156 const users = camelizeKeys ( data . users ) as LiveUser [ ] ;
156157
0 commit comments