@@ -88,21 +88,43 @@ export function Client({
8888 enhancer,
8989 } ) ;
9090
91+ this . gameID = props . gameID ;
92+ this . playerID = props . playerID ;
93+ this . credentials = props . credentials ;
94+
9195 this . client . subscribe ( ( ) => this . forceUpdate ( ) ) ;
9296 }
9397
9498 componentDidUpdate ( prevProps ) {
9599 if ( this . props . gameID != prevProps . gameID ) {
96- this . client . updateGameID ( this . props . gameID ) ;
100+ this . updateGameID ( this . props . gameID ) ;
97101 }
98102 if ( this . props . playerID != prevProps . playerID ) {
99- this . client . updatePlayerID ( this . props . playerID ) ;
103+ this . updatePlayerID ( this . props . playerID ) ;
100104 }
101105 if ( this . props . credentials != prevProps . credentials ) {
102- this . client . updateCredentials ( this . props . credentials ) ;
106+ this . updateCredentials ( this . props . credentials ) ;
103107 }
104108 }
105109
110+ updateGameID = gameID => {
111+ this . client . updateGameID ( gameID ) ;
112+ this . gameID = gameID ;
113+ this . forceUpdate ( ) ;
114+ } ;
115+
116+ updatePlayerID = playerID => {
117+ this . client . updatePlayerID ( playerID ) ;
118+ this . playerID = playerID ;
119+ this . forceUpdate ( ) ;
120+ } ;
121+
122+ updateCredentials = credentials => {
123+ this . client . updateCredentials ( credentials ) ;
124+ this . credentials = credentials ;
125+ this . forceUpdate ( ) ;
126+ } ;
127+
106128 componentDidMount ( ) {
107129 this . client . connect ( ) ;
108130 }
@@ -116,7 +138,7 @@ export function Client({
116138 let _debug = null ;
117139
118140 let state = this . client . getState ( ) ;
119- const { gameID , playerID , debug : debugProp , ...rest } = this . props ;
141+ const { debug : debugProp , ...rest } = this . props ;
120142
121143 if ( this . state . gameStateOverride ) {
122144 state = { ...state , ...this . state . gameStateOverride } ;
@@ -128,8 +150,8 @@ export function Client({
128150 isMultiplayer : multiplayer !== undefined ,
129151 moves : this . client . moves ,
130152 events : this . client . events ,
131- gameID : gameID ,
132- playerID : playerID ,
153+ gameID : this . gameID ,
154+ playerID : this . playerID ,
133155 reset : this . client . reset ,
134156 undo : this . client . undo ,
135157 redo : this . client . redo ,
@@ -145,14 +167,18 @@ export function Client({
145167 isMultiplayer : multiplayer !== undefined ,
146168 moves : this . client . moves ,
147169 events : this . client . events ,
148- gameID : gameID ,
149- playerID : playerID ,
170+ gameID : this . gameID ,
171+ playerID : this . playerID ,
172+ credentials : this . credentials ,
150173 step : this . client . step ,
151174 reset : this . client . reset ,
152175 undo : this . client . undo ,
153176 redo : this . client . redo ,
154177 visualizeAI : ai && ai . visualize ,
155178 overrideGameState : this . overrideGameState ,
179+ updateGameID : this . updateGameID ,
180+ updatePlayerID : this . updatePlayerID ,
181+ updateCredentials : this . updateCredentials ,
156182 } ) ;
157183 }
158184
0 commit comments