Skip to content

Commit

Permalink
user public rooms counter and minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
GitGinocchio committed Feb 23, 2025
1 parent d5a6ea5 commit b927ddf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/web/durables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ export class Room extends DurableObject {
// @ts-ignore
let rooms = await this.env.kv.get("rooms");

console.log("rooms: ", rooms);

if (rooms != null || rooms != "") {
if (rooms != null) {
rooms = JSON.parse(rooms);
} else {
rooms = [];
Expand Down
4 changes: 3 additions & 1 deletion src/web/routes/join/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ export default {
let roomids = await env.kv.get("rooms");

const rooms : Array<Object> = [];

console.log(roomids);

if (roomids != undefined || roomids !== "") {
if (roomids != null) {
roomids = JSON.parse(roomids);

let changed = false;
Expand Down
7 changes: 5 additions & 2 deletions src/web/routes/user/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export default {
const user : User = env.users.get(id);
const data = await user.getData();

// @ts-ignore
let rooms = await env.kv.get("rooms");
rooms = JSON.parse(rooms);

const html = mustache.render(UserPage, {
user : {
name : data.display_name,
Expand All @@ -26,9 +30,8 @@ export default {
//@ts-ignore
url: data.external_urls.spotify
},
num_rooms : Object.keys(env.rooms).length,
num_public_rooms : 0,
num_total_rooms : 0
num_total_rooms : rooms ? rooms.length : 0
});

return new Response(html, { headers: { 'Content-Type': 'text/html' }});
Expand Down
2 changes: 1 addition & 1 deletion src/web/routes/user/user.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h2>Join a Room</h2>
</div>
</div>
<div class="room-container">
<p class="counter-rooms">{{num_rooms}} Total rooms</p>
<p class="counter-rooms">{{num_total_rooms}} Total rooms</p>
</div>
<!--
<footer>
Expand Down

0 comments on commit b927ddf

Please sign in to comment.