11import React from 'react' ;
2- import { inject , observer } from 'app/componentConnectors ' ;
2+ import { useOvermind } from 'app/overmind ' ;
33
44import LiveInfo from './LiveInfo' ;
55import LiveButton from './LiveButton' ;
@@ -12,15 +12,46 @@ import {
1212} from '../../elements' ;
1313import { More } from '../More' ;
1414
15- const Live = ( { signals, store } ) => {
16- const hasUnsyncedModules = ! store . editor . isAllModulesSynced ;
15+ const Live : React . FC = ( ) => {
16+ const {
17+ state : {
18+ isLoggedIn,
19+ live : {
20+ isLive,
21+ isOwner,
22+ isTeam,
23+ roomInfo,
24+ liveUserId,
25+ reconnecting,
26+ notificationsHidden,
27+ followingUserId,
28+ isLoading,
29+ } ,
30+ editor : {
31+ isAllModulesSynced,
32+ currentSandbox : { owned } ,
33+ currentId,
34+ } ,
35+ } ,
36+ actions : {
37+ live : {
38+ onModeChanged,
39+ onAddEditorClicked,
40+ onRemoveEditorClicked,
41+ onSessionCloseClicked,
42+ onToggleNotificationsHidden,
43+ onChatEnabledChange,
44+ onFollow,
45+ createLiveClicked,
46+ } ,
47+ } ,
48+ } = useOvermind ( ) ;
49+ const hasUnsyncedModules = ! isAllModulesSynced ;
1750
18- const showPlaceHolder =
19- ( ! store . live . isLive && ! store . editor . currentSandbox . owned ) ||
20- ! store . isLoggedIn ;
51+ const showPlaceHolder = ( ! isLive && ! owned ) || ! isLoggedIn ;
2152
2253 if ( showPlaceHolder ) {
23- const message = store . isLoggedIn ? (
54+ const message = isLoggedIn ? (
2455 < >
2556 You need to own this sandbox to open a live session to collaborate with
2657 others in real time.{ ' ' }
@@ -35,28 +66,28 @@ const Live = ({ signals, store }) => {
3566
3667 return (
3768 < div >
38- { store . live . isLive ? (
69+ { isLive ? (
3970 < LiveInfo
40- setMode = { signals . live . onModeChanged }
41- addEditor = { signals . live . onAddEditorClicked }
42- removeEditor = { signals . live . onRemoveEditorClicked }
43- isOwner = { store . live . isOwner }
44- isTeam = { store . live . isTeam }
45- roomInfo = { store . live . roomInfo }
46- ownerIds = { store . live . roomInfo . ownerIds }
47- currentUserId = { store . live . liveUserId }
48- reconnecting = { store . live . reconnecting }
49- onSessionCloseClicked = { signals . live . onSessionCloseClicked }
50- notificationsHidden = { store . live . notificationsHidden }
51- toggleNotificationsHidden = { signals . live . onToggleNotificationsHidden }
52- chatEnabled = { store . live . roomInfo . chatEnabled }
71+ setMode = { onModeChanged }
72+ addEditor = { onAddEditorClicked }
73+ removeEditor = { onRemoveEditorClicked }
74+ isOwner = { isOwner }
75+ isTeam = { isTeam }
76+ roomInfo = { roomInfo }
77+ ownerIds = { roomInfo . ownerIds }
78+ currentUserId = { liveUserId }
79+ reconnecting = { reconnecting }
80+ onSessionCloseClicked = { onSessionCloseClicked }
81+ notificationsHidden = { notificationsHidden }
82+ toggleNotificationsHidden = { onToggleNotificationsHidden }
83+ chatEnabled = { roomInfo . chatEnabled }
5384 toggleChatEnabled = { ( ) => {
54- signals . live . onChatEnabledChange ( {
55- enabled : ! store . live . roomInfo . chatEnabled ,
85+ onChatEnabledChange ( {
86+ enabled : ! roomInfo . chatEnabled ,
5687 } ) ;
5788 } }
58- setFollowing = { signals . live . onFollow }
59- followingUserId = { store . live . followingUserId }
89+ setFollowing = { onFollow }
90+ followingUserId = { followingUserId }
6091 />
6192 ) : (
6293 < >
@@ -80,11 +111,11 @@ const Live = ({ signals, store }) => {
80111 < WorkspaceInputContainer >
81112 < LiveButton
82113 onClick = { ( ) => {
83- signals . live . createLiveClicked ( {
84- sandboxId : store . editor . currentId ,
114+ createLiveClicked ( {
115+ sandboxId : currentId ,
85116 } ) ;
86117 } }
87- isLoading = { store . live . isLoading }
118+ isLoading = { isLoading }
88119 disable = { hasUnsyncedModules }
89120 />
90121 </ WorkspaceInputContainer >
@@ -95,4 +126,4 @@ const Live = ({ signals, store }) => {
95126 ) ;
96127} ;
97128
98- export default inject ( 'signals' , 'store' ) ( observer ( Live ) ) ;
129+ export default Live ;
0 commit comments