1- import { useOvermind } from 'app/overmind' ;
21import React , { FunctionComponent } from 'react' ;
32
3+ import { useOvermind } from 'app/overmind' ;
4+
45import {
56 Description ,
67 ErrorDescription ,
78 WorkspaceInputContainer ,
89 WorkspaceSubtitle ,
910} from '../../elements' ;
11+
1012import { More } from '../More' ;
13+
1114import LiveButton from './LiveButton' ;
1215import LiveInfo from './LiveInfo' ;
1316
1417export const Live : FunctionComponent = ( ) => {
1518 const {
19+ actions : {
20+ live : {
21+ createLiveClicked,
22+ onAddEditorClicked,
23+ onChatEnabledChange,
24+ onFollow,
25+ onModeChanged,
26+ onRemoveEditorClicked,
27+ onSessionCloseClicked,
28+ onToggleNotificationsHidden,
29+ } ,
30+ } ,
1631 state : {
17- isLoggedIn,
32+ editor : {
33+ currentSandbox : { id, owned } ,
34+ isAllModulesSynced,
35+ } ,
1836 live : {
37+ followingUserId,
1938 isLive,
39+ isLoading,
2040 isOwner,
2141 isTeam,
22- roomInfo,
2342 liveUserId,
24- reconnecting,
2543 notificationsHidden,
26- followingUserId,
27- isLoading,
28- } ,
29- editor : {
30- isAllModulesSynced,
31- currentSandbox : { owned, id } ,
32- } ,
33- } ,
34- actions : {
35- live : {
36- onModeChanged,
37- onAddEditorClicked,
38- onRemoveEditorClicked,
39- onSessionCloseClicked,
40- onToggleNotificationsHidden,
41- onChatEnabledChange,
42- onFollow,
43- createLiveClicked,
44+ reconnecting,
45+ roomInfo,
4446 } ,
47+ isLoggedIn,
4548 } ,
4649 } = useOvermind ( ) ;
47- const hasUnsyncedModules = ! isAllModulesSynced ;
4850
49- const showPlaceHolder = ( ! isLive && ! owned ) || ! isLoggedIn ;
50-
51- if ( showPlaceHolder ) {
51+ if ( ( ! isLive && ! owned ) || ! isLoggedIn ) {
5252 const message = isLoggedIn ? (
5353 < >
5454 You need to own this sandbox to open a live session to collaborate with
@@ -66,26 +66,22 @@ export const Live: FunctionComponent = () => {
6666 < div >
6767 { isLive ? (
6868 < LiveInfo
69- setMode = { onModeChanged }
7069 addEditor = { onAddEditorClicked }
71- removeEditor = { onRemoveEditorClicked }
70+ chatEnabled = { roomInfo . chatEnabled }
71+ currentUserId = { liveUserId }
72+ followingUserId = { followingUserId }
7273 isOwner = { isOwner }
7374 isTeam = { isTeam }
74- roomInfo = { roomInfo }
75+ notificationsHidden = { notificationsHidden }
76+ onSessionCloseClicked = { onSessionCloseClicked }
7577 ownerIds = { roomInfo . ownerIds }
76- currentUserId = { liveUserId }
7778 reconnecting = { reconnecting }
78- onSessionCloseClicked = { onSessionCloseClicked }
79- notificationsHidden = { notificationsHidden }
80- toggleNotificationsHidden = { onToggleNotificationsHidden }
81- chatEnabled = { roomInfo . chatEnabled }
82- toggleChatEnabled = { ( ) => {
83- onChatEnabledChange ( {
84- enabled : ! roomInfo . chatEnabled ,
85- } ) ;
86- } }
79+ removeEditor = { onRemoveEditorClicked }
80+ roomInfo = { roomInfo }
8781 setFollowing = { onFollow }
88- followingUserId = { followingUserId }
82+ setMode = { onModeChanged }
83+ toggleChatEnabled = { ( ) => onChatEnabledChange ( ! roomInfo . chatEnabled ) }
84+ toggleNotificationsHidden = { onToggleNotificationsHidden }
8985 />
9086 ) : (
9187 < >
@@ -95,29 +91,25 @@ export const Live: FunctionComponent = () => {
9591 re doing it live!
9692 </ Description >
9793
98- < >
99- < WorkspaceSubtitle > Create live room</ WorkspaceSubtitle >
100- < Description >
101- To invite others you need to generate a URL that others can join.
102- </ Description >
94+ < WorkspaceSubtitle > Create live room</ WorkspaceSubtitle >
95+
96+ < Description >
97+ To invite others you need to generate a URL that others can join.
98+ </ Description >
99+
100+ { ! isAllModulesSynced && (
101+ < ErrorDescription >
102+ Save all your files before going live
103+ </ ErrorDescription >
104+ ) }
103105
104- { hasUnsyncedModules && (
105- < ErrorDescription >
106- Save all your files before going live
107- </ ErrorDescription >
108- ) }
109- < WorkspaceInputContainer >
110- < LiveButton
111- onClick = { ( ) => {
112- createLiveClicked ( {
113- sandboxId : id ,
114- } ) ;
115- } }
116- isLoading = { isLoading }
117- disable = { hasUnsyncedModules }
118- />
119- </ WorkspaceInputContainer >
120- </ >
106+ < WorkspaceInputContainer >
107+ < LiveButton
108+ disable = { ! isAllModulesSynced }
109+ isLoading = { isLoading }
110+ onClick = { ( ) => createLiveClicked ( id ) }
111+ />
112+ </ WorkspaceInputContainer >
121113 </ >
122114 ) }
123115 </ div >
0 commit comments