// FIXME: This file should handle the rooms API // Functions may include: import { subscribe } from "../utils/streams"; import { authedAPIRequest } from "../utils/auth"; // - fetchRoomConfig (get the configuration of a room) export async function fetchRoomConfig(slug) { const config = { method: "get", }; return authedAPIRequest(`/rooms/${slug}/config`, config) .then(async (res) => { if (!res) { return null; } const response = await res.json(); document.getElementById("room-name").innerHTML = response.metadata.name; const description = document.getElementById("room-description"); if (response.metadata.description) { description.innerHTML = response.metadata.description; description.style.display = "inherit"; } else { description.style.display = "none"; } return response; }) .catch((error) => { console.log(error); return null; }); } // - joinRoom (join a room by its slug) export function joinRoom(slug) { if (!slug) { slug = "epi-place"; } subscribe(slug); } // - listRooms (list all the rooms available) // - createRoom (create a room) // - updateRoom (update a room's configuration) // - deleteRoom (delete a room)