non mais srx
This commit is contained in:
parent
b7d988048b
commit
34e5527244
2 changed files with 13 additions and 9 deletions
|
|
@ -19,7 +19,7 @@ await authenticate();
|
||||||
// Sockets
|
// Sockets
|
||||||
//
|
//
|
||||||
let room = window.location.pathname.split("/")[1];
|
let room = window.location.pathname.split("/")[1];
|
||||||
let update_waitlist = []
|
const update_waitlist = [];
|
||||||
let initialized = false;
|
let initialized = false;
|
||||||
|
|
||||||
if (!room) {
|
if (!room) {
|
||||||
|
|
@ -53,11 +53,15 @@ socket.on("message", async (response) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
initCanvas(await getCurrentRoomConfig(room), pixels);
|
initCanvas(await getCurrentRoomConfig(room), pixels);
|
||||||
|
initialized = true;
|
||||||
while (update_waitlist.length > 0) {
|
while (update_waitlist.length > 0) {
|
||||||
const obj = update_waitlist.pop()
|
const obj = update_waitlist.pop();
|
||||||
if (obj)
|
|
||||||
renderCanvasUpdate(obj.color, obj.posX, obj.posY)
|
if (obj) {
|
||||||
|
renderCanvasUpdate(obj.color, obj.posX, obj.posY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.debug("Loaded canvas");
|
console.debug("Loaded canvas");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -79,9 +83,10 @@ socket.on("pixel-update", async (msg) => {
|
||||||
} = msg.result.data.json;
|
} = msg.result.data.json;
|
||||||
|
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
update_waitlist.push({posX, posY, color})
|
update_waitlist.push({ posX, posY, color });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderCanvasUpdate(color, posX, posY);
|
renderCanvasUpdate(color, posX, posY);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -103,6 +108,4 @@ placeButtonElt.addEventListener("click", () => {
|
||||||
placePixelButton();
|
placePixelButton();
|
||||||
});
|
});
|
||||||
|
|
||||||
export {
|
export { room };
|
||||||
room
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,8 @@ async function fetchRoomConfig(room) {
|
||||||
|
|
||||||
// Update HTML
|
// Update HTML
|
||||||
document.getElementById("room-name").innerText = res.metadata.name;
|
document.getElementById("room-name").innerText = res.metadata.name;
|
||||||
document.getElementById("room-description").innerText = res.metadata.description;
|
document.getElementById("room-description").innerText =
|
||||||
|
res.metadata.description;
|
||||||
document.getElementById("room-description").style.display = "block";
|
document.getElementById("room-description").style.display = "block";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue