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 ;
48-
4950 const showPlaceHolder = ( ! isLive && ! owned ) || ! isLoggedIn ;
5051
5152 if ( showPlaceHolder ) {
@@ -66,26 +67,22 @@ export const Live: FunctionComponent = () => {
6667 < div >
6768 { isLive ? (
6869 < LiveInfo
69- setMode = { onModeChanged }
7070 addEditor = { onAddEditorClicked }
71- removeEditor = { onRemoveEditorClicked }
71+ chatEnabled = { roomInfo . chatEnabled }
72+ currentUserId = { liveUserId }
73+ followingUserId = { followingUserId }
7274 isOwner = { isOwner }
7375 isTeam = { isTeam }
74- roomInfo = { roomInfo }
76+ notificationsHidden = { notificationsHidden }
77+ onSessionCloseClicked = { onSessionCloseClicked }
7578 ownerIds = { roomInfo . ownerIds }
76- currentUserId = { liveUserId }
7779 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- } }
80+ removeEditor = { onRemoveEditorClicked }
81+ roomInfo = { roomInfo }
8782 setFollowing = { onFollow }
88- followingUserId = { followingUserId }
83+ setMode = { onModeChanged }
84+ toggleChatEnabled = { ( ) => onChatEnabledChange ( ! roomInfo . chatEnabled ) }
85+ toggleNotificationsHidden = { onToggleNotificationsHidden }
8986 />
9087 ) : (
9188 < >
@@ -95,29 +92,25 @@ export const Live: FunctionComponent = () => {
9592 re doing it live!
9693 </ Description >
9794
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 >
95+ < WorkspaceSubtitle > Create live room</ WorkspaceSubtitle >
96+
97+ < Description >
98+ To invite others you need to generate a URL that others can join.
99+ </ Description >
100+
101+ { ! isAllModulesSynced && (
102+ < ErrorDescription >
103+ Save all your files before going live
104+ </ ErrorDescription >
105+ ) }
103106
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- </ >
107+ < WorkspaceInputContainer >
108+ < LiveButton
109+ disable = { ! isAllModulesSynced }
110+ isLoading = { isLoading }
111+ onClick = { ( ) => createLiveClicked ( id ) }
112+ />
113+ </ WorkspaceInputContainer >
121114 </ >
122115 ) }
123116 </ div >
0 commit comments