blob: dde88e68443eb36a977ca3f0e8ee2cee5fa92a69 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// 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)
|