File tree Expand file tree Collapse file tree
services/app/assets/js/widgets Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import React , { useContext } from 'react' ;
2+ import { networkMachineStates } from '../machines/game' ;
3+ import GameContext from './GameContext' ;
4+
5+ const NetworkAlert = ( ) => {
6+ const { current : gameCurrent } = useContext ( GameContext ) ;
7+
8+ if ( gameCurrent . matches ( { network : networkMachineStates . disconnected } ) ) {
9+ return < div className = "col-12 bg-warning text-center" > Check your network connection</ div > ;
10+ }
11+
12+ return ( < > </ > ) ;
13+ } ;
14+
15+ export default NetworkAlert ;
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import FeedBackWidget from '../components/FeedBackWidget';
2020import GamePreview from '../components/Game/GamePreview' ;
2121import { replayerMachineStates } from '../machines/game' ;
2222import AnimationModal from '../components/AnimationModal' ;
23+ import NetworkAlert from './NetworkAlert' ;
2324
2425const steps = [
2526 {
@@ -235,6 +236,7 @@ const RootContainer = ({
235236 < GameContext . Provider value = { { current, send, service } } >
236237 < div className = "x-outline-none" >
237238 < GameWidgetGuide />
239+ < NetworkAlert />
238240 < div className = "container-fluid" >
239241 < div className = "row no-gutter cb-game" >
240242 < AnimationModal setModalShowing = { setModalShowing } modalShowing = { modalShowing } />
Original file line number Diff line number Diff line change @@ -77,7 +77,8 @@ const machine = {
7777 none : {
7878 on : {
7979 JOIN : { target : 'connected' } ,
80- FAILURE : { target : 'disconnected' , actions : [ 'handleFailureJoin' ] } ,
80+ FAILURE_JOIN : { target : 'disconnected' , actions : [ 'handleFailureJoin' ] } ,
81+ FAILURE : { target : 'disconnected' , actions : [ 'handleDisconnection' ] } ,
8182 } ,
8283 } ,
8384 disconnected : {
@@ -265,9 +266,15 @@ const states = {
265266 ended : 'on.ended' ,
266267 off : 'off' ,
267268 } ,
269+ network : {
270+ none : 'none' ,
271+ disconnected : 'disconnected' ,
272+ connected : 'connected' ,
273+ } ,
268274} ;
269275
270276export const gameMachineStates = states . game ;
271277export const replayerMachineStates = states . replayer ;
278+ export const networkMachineStates = states . network ;
272279
273280export default machine ;
You can’t perform that action at this time.
0 commit comments