Skip to content

Commit c4b8d61

Browse files
committed
fix(game): reset timers on game disconnect to prevent UI inconsistencies
1 parent b4fd78e commit c4b8d61

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

electron/renderer/components/game/game-roundtime.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,15 @@ export const GameRoundTime: React.FC = (): ReactNode => {
7272
}
7373
});
7474

75+
// Clear the counters otherwise they continue to tick down in the UI.
76+
// I also tried clearing the interval, but because the component is still
77+
// mounted then even when reconnecting to the game or reloading the page
78+
// then the interval wasn't restarting and the numbers were frozen.
79+
// This was the simplest solution I landed on.
7580
useSubscribe('game:disconnect', () => {
76-
clearInterval(intervalRef.current);
77-
setCurrentRT(0);
78-
setCurrentCT(0);
81+
serverTimeRef.current = 0;
82+
roundTimeRef.current = 0;
83+
castTimeRef.current = 0;
7984
});
8085

8186
const roundTimeCmp = useMemo((): ReactElement => {

0 commit comments

Comments
 (0)