File tree Expand file tree Collapse file tree 5 files changed +33
-7
lines changed
Expand file tree Collapse file tree 5 files changed +33
-7
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,9 @@ window.__isTouch = !matchMedia('(pointer:fine)').matches;
5151
5252const overmind = createOvermind ( config , {
5353 devtools :
54- ( window . opener && window . opener !== window ) || ! window . chrome
54+ ( window . opener && window . opener !== window ) ||
55+ ! window . chrome ||
56+ location . search . includes ( 'noDevtools' )
5557 ? false
5658 : 'localhost:3031' ,
5759 name :
Original file line number Diff line number Diff line change @@ -144,6 +144,21 @@ export const applyTransformation: AsyncAction<{
144144 }
145145} ;
146146
147+ export const sendCurrentSelection : Action = ( { state, effects } ) => {
148+ if ( ! state . live . roomInfo ) {
149+ return ;
150+ }
151+
152+ if ( state . live . isCurrentEditor ) {
153+ const { liveUserId } = state . live ;
154+ effects . live . sendUserSelection (
155+ state . editor . currentModuleShortid ,
156+ liveUserId ,
157+ state . live . currentSelection
158+ ) ;
159+ }
160+ } ;
161+
147162export const onSelectionChanged : Action < any > = (
148163 { state, effects } ,
149164 selection
@@ -158,6 +173,8 @@ export const onSelectionChanged: Action<any> = (
158173 if ( ! moduleShortid || ! liveUserId ) {
159174 return ;
160175 }
176+
177+ state . live . currentSelection = selection ;
161178 const userIndex = state . live . roomInfo . users . findIndex (
162179 u => u . id === liveUserId
163180 ) ;
Original file line number Diff line number Diff line change @@ -20,12 +20,11 @@ export const clearUserSelections: Action<string | null> = (
2020 const roomInfo = state . live . roomInfo ! ;
2121 const userIndex = roomInfo . users . findIndex ( u => u . id === userId ) ;
2222
23+ effects . vscode . clearUserSelections ( userId ) ;
2324 if ( userIndex > - 1 ) {
2425 const user = roomInfo . users [ userIndex ] ;
2526 if ( user ) {
2627 user . selection = null ;
27-
28- effects . vscode . clearUserSelections ( userId ) ;
2928 }
3029 }
3130 } ;
Original file line number Diff line number Diff line change @@ -71,6 +71,10 @@ export const onUserEntered: Operator<LiveMessage<{
7171 ) ;
7272 }
7373
74+ // Send our own selections to everyone, just to let the others know where
75+ // we are
76+ actions . live . sendCurrentSelection ( ) ;
77+
7478 if ( data . joined_user_id === state . live . liveUserId ) {
7579 return ;
7680 }
@@ -101,9 +105,7 @@ export const onUserLeft: Operator<LiveMessage<{
101105
102106 if ( user && user . id !== state . live . liveUserId ) {
103107 effects . notificationToast . add ( {
104- message : user
105- ? `${ user . username } left the live session.`
106- : 'Someone left the live session' ,
108+ message : `${ user . username } left the live session.` ,
107109 status : NotificationStatus . NOTICE ,
108110 } ) ;
109111 }
Original file line number Diff line number Diff line change 1- import { LiveUser , RoomInfo } from '@codesandbox/common/lib/types' ;
1+ import {
2+ LiveUser ,
3+ RoomInfo ,
4+ UserSelection ,
5+ } from '@codesandbox/common/lib/types' ;
26import { Derive } from 'app/overmind' ;
37
48type State = {
@@ -11,6 +15,7 @@ type State = {
1115 followingUserId : string | null ;
1216 liveUserId : string | null ;
1317 roomInfo : RoomInfo | null ;
18+ currentSelection : UserSelection | null ;
1419 liveUser : Derive < State , LiveUser | null > ;
1520 isEditor : Derive < State , ( liveUserId : string ) => boolean > ;
1621 isCurrentEditor : Derive < State , boolean > ;
@@ -33,6 +38,7 @@ export const state: State = {
3338 error : null ,
3439 liveUserId : null ,
3540 roomInfo : null ,
41+ currentSelection : null ,
3642 liveUser : currentState =>
3743 currentState . roomInfo ?. users . find ( u => u . id === currentState . liveUserId ) ||
3844 null ,
You can’t perform that action at this time.
0 commit comments