hnininini

This commit is contained in:
Guillem George 2026-05-16 16:25:05 +02:00
parent 8cab4ac558
commit 50d46d0f0c
3 changed files with 59 additions and 33 deletions

View file

@ -12,15 +12,16 @@ import { resetValues } from "./canvas/utils";
// - updateRoom (update a room's configuration)
// - deleteRoom (delete a room)
let roomConfig = null;
function setCurrentRoomConfig(cfg) {
roomConfig = cfg;
}
async function getCurrentRoomConfig() {
if (!roomConfig)
if (!roomConfig) {
await fetchRoomConfig();
}
return roomConfig;
}
async function joinRoom(room) {
@ -45,8 +46,12 @@ async function joinRoom(room) {
async function listRooms() {
const response = await authedAPIRequest("/rooms/", { method: "GET" });
if (!response.ok) {
console.error("Could not retrieve rooms list: " + response.statusText);
if (!response || !response.ok) {
console.error(
"Could not retrieve rooms list: " + response
? response.statusText
: "null",
);
console.debug(await response.text());
return;
}
@ -80,8 +85,12 @@ async function fetchRoomConfig(room) {
method: "GET",
});
if (!response.ok) {
console.error("Could not retrieve room config: " + response.statusText);
if (!response || !response.ok) {
console.error(
"Could not retrieve room config" + response
? response.statusText
: "null",
);
console.debug(await response.text());
return;
}