home rooms are charging correctly

This commit is contained in:
simplonco
2023-01-07 19:36:07 +01:00
parent d21c1d1e4e
commit e4a3504564
8 changed files with 316 additions and 134 deletions

View File

@@ -12,16 +12,15 @@
{room_name: 'ho room'},
];
// ask for the rooms
onMount(() => {
console.log("onmount");
const get_rooms = fetch('/api/v2/chat/rooms')
.then(resp => resp.json())
.then(data =>
{
console.log(data);
//rooms = data;
});
// ask api for the rooms
const get_rooms = fetch('/api/v2/chat/rooms')
.then(resp => resp.json())
.then(data =>
{
console.log(data.rooms);
for (let room of data.rooms)
console.log(room.name);
rooms = data.rooms;
});
</script>
@@ -50,11 +49,16 @@
<div class="__show_if_only_child">
<p class="__center">/ you have no chat room yet /</p>
</div>
{#each rooms as room}
<Button bind:layout new_layout="room" my_class="list">
{room.room_name}
</Button>
{/each}
{#await get_rooms}
<!-- promise is pending -->
<p>rooms are loaded...</p>
{:then}
{#each rooms as room}
<Button bind:layout new_layout="room" my_class="list">
{room.name}
</Button>
{/each}
{/await}
<!-- placeholders
<Button bind:layout new_layout="room" my_class="list">