Skip to content

Commit

Permalink
Cancel game progress spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
lindlof committed Dec 6, 2020
1 parent 2abb9e7 commit bee3605
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
15 changes: 1 addition & 14 deletions web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const App: React.FC = () => {
playHandsign(client, game, handsign, setGame, enqueueSnackbar)
}
leaveGame={() => setGame(undefined)}
claimInactivity={() => claimInactivity(client, game, setGame, enqueueSnackbar)}
claimInactivity={async () => setGame(await Game.claimInactivity(client, game))}
enqueueSnackbar={enqueueSnackbar}
/>
</GameTicker>
Expand Down Expand Up @@ -137,17 +137,4 @@ const playHandsign = async (
}
};

const claimInactivity = async (
client: SecretJS.SigningCosmWasmClient,
game: Game.Game,
setGame: Function,
enqueueSnackbar: Function,
): Promise<void> => {
try {
setGame(await Game.claimInactivity(client, game));
} catch (error) {
enqueueSnackbar('Secret error', { variant: 'error' });
}
};

export default App;
11 changes: 8 additions & 3 deletions web/src/GamePlaying.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default (props: Props) => {
try {
await claimInactivity();
} catch {
enqueueSnackbar('Secret error', { variant: 'error' });
setClaimingInactivity(false);
}
};
Expand Down Expand Up @@ -122,9 +123,13 @@ export default (props: Props) => {
)}
<Grid item>
<Typography>Waiting for other player</Typography>
<Button variant="contained" color="primary" onClick={tryClaimInactivity}>
Cancel game
</Button>
{claimingInactivity ? (
<CircularProgress />
) : (
<Button variant="contained" color="primary" onClick={tryClaimInactivity}>
Cancel game
</Button>
)}
</Grid>
</Grid>
</Container>
Expand Down

0 comments on commit bee3605

Please sign in to comment.