@@ -3,63 +3,156 @@ import { inject, observer } from 'mobx-react';
33import { Link } from 'react-router-dom' ;
44import { DragDropContext } from 'react-dnd' ;
55import HTML5Backend from 'react-dnd-html5-backend' ;
6- import QuickActions from 'app/pages/Sandbox/QuickActions' ;
76
7+ import Navigation from 'app/pages/common/Navigation' ;
8+ import Fullscreen from 'common/components/flex/Fullscreen' ;
9+
10+ import QuickActions from 'app/pages/Sandbox/QuickActions' ;
811import Title from 'app/components/Title' ;
912import SubTitle from 'app/components/SubTitle' ;
1013import Centered from 'common/components/flex/Centered' ;
1114import Skeleton from 'app/components/Skeleton' ;
15+ import Padding from 'common/components/spacing/Padding' ;
16+ import SignInButton from 'app/pages/common/SignInButton' ;
1217
1318import Editor from '../Sandbox/Editor' ;
19+ import BlinkingDot from './BlinkingDot' ;
1420
1521class LivePage extends React . Component {
22+ loggedIn = this . props . store . hasLogIn ;
23+
1624 componentWillMount ( ) {
1725 this . initializeLive ( ) ;
1826 }
1927
2028 initializeLive = ( ) => {
21- this . props . signals . live . roomJoined ( {
22- roomId : this . props . match . params . id ,
23- } ) ;
29+ if ( this . props . store . hasLogIn ) {
30+ this . loggedIn = true ;
31+ this . props . signals . live . roomJoined ( {
32+ roomId : this . props . match . params . id ,
33+ } ) ;
34+ }
2435 } ;
2536
2637 componentDidUpdate ( prevProps ) {
27- if ( prevProps . match . params . id !== this . props . match . params . id ) {
38+ if (
39+ prevProps . match . params . id !== this . props . match . params . id ||
40+ ( this . props . store . hasLogIn && ! this . loggedIn )
41+ ) {
2842 this . initializeLive ( ) ;
2943 }
3044 }
3145
32- render ( ) {
33- const { match, store } = this . props ;
46+ getContent = ( ) => {
47+ const { store } = this . props ;
48+
49+ if ( ! store . hasLogIn ) {
50+ return (
51+ < React . Fragment >
52+ < div
53+ style = { {
54+ fontWeight : 300 ,
55+ color : 'rgba(255, 255, 255, 0.5)' ,
56+ marginBottom : '1rem' ,
57+ fontSize : '1.5rem' ,
58+ } }
59+ >
60+ Sign in required
61+ </ div >
62+ < Title style = { { fontSize : '1.25rem' } } >
63+ You need to sign in to join this session
64+ </ Title >
65+ < br />
66+ < div >
67+ < SignInButton />
68+ </ div >
69+ </ React . Fragment >
70+ ) ;
71+ }
72+
73+ if ( store . live . error ) {
74+ if ( store . live . error === 'room not found' ) {
75+ return (
76+ < React . Fragment >
77+ < div
78+ style = { {
79+ fontWeight : 300 ,
80+ color : 'rgba(255, 255, 255, 0.5)' ,
81+ marginBottom : '1rem' ,
82+ fontSize : '1.5rem' ,
83+ } }
84+ >
85+ Something went wrong
86+ </ div >
87+ < Title style = { { fontSize : '1.25rem' } } >
88+ It seems like this session doesn{ "'" } t exist or has been closed
89+ </ Title >
90+ < br />
91+ < Link to = "/s" > Create Sandbox</ Link >
92+ </ React . Fragment >
93+ ) ;
94+ }
3495
35- if ( store . live . isLoading ) {
3696 return (
37- < Centered horizontal vertical >
97+ < React . Fragment >
98+ < Title > An error occured while connecting to the live session:</ Title >
99+ < SubTitle > { store . live . error } </ SubTitle >
100+ < br />
101+ < br />
102+ < Link to = "/s" > Create Sandbox</ Link >
103+ </ React . Fragment >
104+ ) ;
105+ }
106+
107+ if ( store . live . isLoading || ! store . editor . currentSandbox ) {
108+ return (
109+ < React . Fragment >
38110 < Skeleton
39111 titles = { [
40112 {
41- content : 'Loading sandbox...' ,
113+ content : < BlinkingDot /> ,
42114 delay : 0 ,
43115 } ,
44116 {
45- content : 'Fetching git repository ...' ,
46- delay : 2 ,
117+ content : 'Joining Live Session ...' ,
118+ delay : 0.5 ,
47119 } ,
48120 ] }
49121 />
50- </ Centered >
122+ </ React . Fragment >
51123 ) ;
52124 }
53125
54- if ( store . live . error ) {
126+ return null ;
127+ } ;
128+
129+ render ( ) {
130+ const { match, store } = this . props ;
131+
132+ const content = this . getContent ( ) ;
133+
134+ if ( content ) {
55135 return (
56- < Centered style = { { height : '100vh' } } horizontal vertical >
57- < Title > An error occured when connecting to the live session:</ Title >
58- < SubTitle > { store . editor . error } </ SubTitle >
59- < br />
60- < br />
61- < Link to = "/s" > Create Sandbox</ Link >
62- </ Centered >
136+ < Fullscreen >
137+ < Padding
138+ style = { {
139+ display : 'flex' ,
140+ flexDirection : 'column' ,
141+ width : '100vw' ,
142+ height : '100vh' ,
143+ } }
144+ margin = { 1 }
145+ >
146+ < Navigation title = "Live Session" />
147+ < Centered
148+ style = { { flex : 1 , width : '100%' , height : '100%' } }
149+ horizontal
150+ vertical
151+ >
152+ { content }
153+ </ Centered >
154+ </ Padding >
155+ </ Fullscreen >
63156 ) ;
64157 }
65158
0 commit comments