mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-02 21:44:06 +08:00
fixed graphs duplicating
This commit is contained in:
parent
acf6e91e01
commit
a625461800
2 changed files with 21 additions and 4 deletions
|
|
@ -585,3 +585,17 @@ export function cleanTypographySymbols(textToClean) {
|
|||
};
|
||||
return textToClean.replace(/[“”’‘—,…«»–]/g, (char) => specials[char] || "");
|
||||
}
|
||||
|
||||
function forEachWithCallback(callback) {
|
||||
const arrayCopy = this;
|
||||
let index = 0;
|
||||
const next = () => {
|
||||
index++;
|
||||
if (arrayCopy.length > 0) {
|
||||
callback(arrayCopy.shift(), index, next);
|
||||
}
|
||||
};
|
||||
next();
|
||||
}
|
||||
|
||||
Array.prototype.forEachWithCallback = forEachWithCallback;
|
||||
|
|
|
|||
|
|
@ -1141,14 +1141,17 @@ MP.socket.on("mp_room_user_finished", (data) => {
|
|||
if (data.sid === MP.socket.id) {
|
||||
MP.room.userFinished = true;
|
||||
|
||||
Object.keys(MP.room.userGraphs).forEach((sid) => {
|
||||
let userGraph = MP.room.userGraphs[sid];
|
||||
userGraph.graph = drawMinigraph(sid, userGraph.data);
|
||||
Object.keys(MP.room.userGraphs).forEachWithCallback((sid, i, next) => {
|
||||
setTimeout(() => {
|
||||
let userGraph = MP.room.userGraphs[sid];
|
||||
userGraph.graph = drawMinigraph(sid, userGraph.data);
|
||||
next();
|
||||
}, 1);
|
||||
});
|
||||
} else if (MP.room.userFinished) {
|
||||
MP.room.userGraphs[data.sid].graph = drawMinigraph(data.sid, data.result);
|
||||
}
|
||||
}, 500);
|
||||
}, 250);
|
||||
|
||||
// $(`.tribeResult table .player[sid=${data.sid}] .progress`),
|
||||
// swapElements(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue