File tree 3 files changed +10
-7
lines changed
3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ function Board({gameState, setGameState}) {
81
81
let [ cursor_x , setCursor_x ] = useState ( - 1 )
82
82
let [ cursor_y , setCursor_y ] = useState ( - 1 )
83
83
let timeout = useTimeoutStore ( state => state . timeout )
84
+ let fulltime = useTimeoutStore ( state => state . fulltime )
84
85
let setTimeout = useTimeoutStore ( state => state . setTimeout )
85
86
let timeoutRef = useRef ( )
86
87
timeoutRef . current = timeout
@@ -113,7 +114,7 @@ function Board({gameState, setGameState}) {
113
114
if ( intervalIdRef . current ) {
114
115
clearInterval ( intervalIdRef . current )
115
116
}
116
- setTimeout ( 10 )
117
+ setTimeout ( fulltime )
117
118
intervalIdRef . current = setInterval ( ( ) => {
118
119
let t = timeoutRef . current - 1
119
120
setTimeout ( t )
@@ -122,7 +123,7 @@ function Board({gameState, setGameState}) {
122
123
}
123
124
} , 1000 )
124
125
125
- } , [ setTimeout ] )
126
+ } , [ setTimeout , fulltime ] )
126
127
127
128
useEffect ( ( ) => {
128
129
resetCountdown ( )
Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ function WhoIsWho({gameState}) {
87
87
let { black, white, counting} = gameState
88
88
let end = gameHasEnded ( gameState )
89
89
let timeout = useTimeoutStore ( state => state . timeout )
90
+ let fulltime = useTimeoutStore ( state => state . fulltime )
90
91
let color = currentColor ( gameState )
91
92
let navigate = useNavigate ( )
92
93
let onExit = useCallback ( ( ) => {
@@ -106,9 +107,9 @@ function WhoIsWho({gameState}) {
106
107
< IoMdExit />
107
108
</ IconContext . Provider >
108
109
</ button >
109
- < div > { ! counting && ! end && color === WHITE ? timeout : "10" } </ div >
110
+ < div > { ! counting && ! end && color === WHITE ? timeout : fulltime } </ div >
110
111
< div />
111
- < div > { ! counting && ! end && color === BLACK ? timeout : "10" } </ div >
112
+ < div > { ! counting && ! end && color === BLACK ? timeout : fulltime } </ div >
112
113
< div />
113
114
< div />
114
115
</ div >
Original file line number Diff line number Diff line change @@ -48,9 +48,10 @@ export const useMuteStore = create(
48
48
49
49
export const useTimeoutStore = create ( set => (
50
50
{
51
+ fulltime : 10 ,
51
52
timeout : 10 ,
52
- setTimeout : timeout => set ( {
53
- timeout : timeout ,
54
- } )
53
+ setTimeout : timeout => set ( produce ( draft => {
54
+ draft . timeout = timeout
55
+ } ) , true )
55
56
}
56
57
) )
You can’t perform that action at this time.
0 commit comments