@@ -124,7 +124,6 @@ function GamePage({ match }) {
124124
125125 const [ game , loadingGame ] = useFirebaseRef ( `games/${ gameId } ` ) ;
126126 const [ gameData , loadingGameData ] = useFirebaseRef ( `gameData/${ gameId } ` ) ;
127- const newEvents = useRef ( new Set ( ) ) ;
128127 const [ hasNextGame ] = useFirebaseRef (
129128 game ?. status === "done" && ( ! game . users || ! ( user . id in game . users ) )
130129 ? `games/${ nextGameId } /status`
@@ -202,11 +201,7 @@ function GamePage({ match }) {
202201 lastKeptSet,
203202 } = useMemo ( ( ) => {
204203 if ( ! gameData ) return { } ;
205- const state = computeState (
206- { ...gameData , random, deck } ,
207- gameMode ,
208- newEvents . current
209- ) ;
204+ const state = computeState ( { ...gameData , random, deck } , gameMode ) ;
210205 const { current, boardSize, findState, history } = state ;
211206 const board = current . slice ( 0 , boardSize ) ;
212207 const answer = findSet ( board , gameMode , findState ) ;
@@ -256,29 +251,14 @@ function GamePage({ match }) {
256251 if ( numHints ) {
257252 firebase . database ( ) . ref ( `gameData/${ gameId } /hints` ) . remove ( ) ;
258253 }
259- const eventRef = firebase
254+ firebase
260255 . database ( )
261256 . ref ( `gameData/${ gameId } /events` )
262257 . push ( {
263258 ...event ,
264259 user : user . id ,
265260 time : firebase . database . ServerValue . TIMESTAMP ,
266261 } ) ;
267- // Track "new" events that have approximate times. An event is new since
268- // the time it was created until its time is updated from the server.
269- // This happens when our callback is called the second time (the first
270- // time it is called with the approximate time).
271- const eventKey = eventRef . key ;
272- const timeRef = eventRef . child ( "time" ) ;
273- newEvents . current . add ( eventKey ) ;
274- let updateCount = 0 ;
275- const timeUpdated = ( ) => {
276- if ( ++ updateCount === 2 ) {
277- newEvents . current . delete ( eventKey ) ;
278- timeRef . off ( "value" , timeUpdated ) ;
279- }
280- } ;
281- timeRef . on ( "value" , timeUpdated ) ;
282262 }
283263
284264 const hint = game . enableHint && answer ? answer . slice ( 0 , numHints ) : null ;
0 commit comments