mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
more barcode game stuff
This commit is contained in:
@@ -67,11 +67,29 @@ export default function useBarcodeGameState() {
|
||||
[socket],
|
||||
);
|
||||
|
||||
const resetActiveGame = useCallback(
|
||||
() =>
|
||||
new Promise((resolve, reject) => {
|
||||
socket.emit('barcodeGame:resetActive', {}, (response = {}) => {
|
||||
if (response.error) {
|
||||
reject(new Error(response.error));
|
||||
return;
|
||||
}
|
||||
if (response.state) {
|
||||
setState(normalizeState(response.state));
|
||||
}
|
||||
resolve(response);
|
||||
});
|
||||
}),
|
||||
[socket],
|
||||
);
|
||||
|
||||
return useMemo(
|
||||
() => ({
|
||||
state,
|
||||
resetActiveGame,
|
||||
voteForGame,
|
||||
}),
|
||||
[state, voteForGame],
|
||||
[resetActiveGame, state, voteForGame],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user