room load old message but pbm to read them

This commit is contained in:
simplonco
2023-01-08 14:18:57 +01:00
parent c41c7de745
commit c5ed704a62
7 changed files with 143 additions and 116 deletions

View File

@@ -27,7 +27,7 @@
console.log("formData:", formData);
// send the new room
const response = await fetch('/api/v2/chat/join', {
const response = await fetch('/api/v2/chat/create', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(formData),

View File

@@ -18,23 +18,28 @@
.then(resp => resp.json())
.then(data =>
{
console.log(data.rooms);
console.log("data.rooms:", data.rooms);
for (let room of data.rooms)
console.log(room.name);
rooms = data.rooms;
});
/*
function get_room_messages()
{
console.log("in get_room_messages");
const messages = fetch('/api/v2/chat/messages')
.then(resp => resp.json())
.then(data =>
{
console.log(data.messages);
msgs.update(msgs => [...msgs, { name: name, message: message }]);
msgs.update(msgs => msgs.concat(data.messages));
});
layout = "room";
}
function test() {
console.log("test");
}
/*
*/
</script>
@@ -68,7 +73,7 @@
<p>rooms are loaded...</p>
{:then}
{#each rooms as room}
<Button bind:layout new_layout="room" my_class="list">
<Button my_class="list" on_click={get_room_messages}>
{room.name}
</Button>
{/each}