fixed graphs duplicating

This commit is contained in:
Miodec 2021-02-05 04:06:38 +00:00
parent acf6e91e01
commit a625461800
2 changed files with 21 additions and 4 deletions

View file

@ -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;

View file

@ -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(