mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-02 21:44:06 +08:00
add raceFinished event
This commit is contained in:
parent
d3dfc08b87
commit
2c06faace8
2 changed files with 14 additions and 6 deletions
|
|
@ -222,12 +222,15 @@ function userResult(
|
|||
callback: (data: {
|
||||
userId: string;
|
||||
result: TribeTypes.Result | undefined;
|
||||
everybodyCompleted: boolean;
|
||||
}) => void,
|
||||
): void {
|
||||
Socket.on("room_user_result", callback);
|
||||
}
|
||||
|
||||
function raceFinished(callback: () => void): void {
|
||||
Socket.on("room_race_finished", callback);
|
||||
}
|
||||
|
||||
function finishTimerCountdown(
|
||||
callback: (data: { time: number }) => void,
|
||||
): void {
|
||||
|
|
@ -287,6 +290,7 @@ export default {
|
|||
countdown,
|
||||
usersUpdate,
|
||||
raceStarted,
|
||||
raceFinished,
|
||||
progressUpdate,
|
||||
userResult,
|
||||
finishTimerCountdown,
|
||||
|
|
|
|||
|
|
@ -730,11 +730,7 @@ TribeSocket.in.room.userResult((data) => {
|
|||
TribeResults.update("result", data.userId);
|
||||
TribeUserList.update("result");
|
||||
setTimeout(async () => {
|
||||
if (data.everybodyCompleted) {
|
||||
await TribeChartController.drawAllCharts();
|
||||
} else {
|
||||
await TribeChartController.drawChart(data.userId);
|
||||
}
|
||||
await TribeChartController.drawChart(data.userId);
|
||||
if (TribeState.getState() >= 21) {
|
||||
void TribeChartController.updateChartMaxValues();
|
||||
}
|
||||
|
|
@ -742,6 +738,14 @@ TribeSocket.in.room.userResult((data) => {
|
|||
}
|
||||
});
|
||||
|
||||
TribeSocket.in.room.raceFinished(() => {
|
||||
if (!TestState.isActive) {
|
||||
setTimeout(() => {
|
||||
void TribeChartController.drawAllCharts();
|
||||
}, 250);
|
||||
}
|
||||
});
|
||||
|
||||
TribeSocket.in.room.finishTimerCountdown((data) => {
|
||||
if (TestState.isActive) {
|
||||
TribeCountdown.update(data.time.toString());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue