can create and join rooms, but messages are all mixed up
This commit is contained in:
@@ -36,7 +36,8 @@
|
||||
item.name = "me";
|
||||
}
|
||||
});
|
||||
msgs.update(msgs => msgs.concat(data.messages));
|
||||
//msgs.update(msgs => msgs.concat(data.messages));
|
||||
msgs.update(msgs => msgs = data.messages);
|
||||
});
|
||||
layout = "room";
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script>
|
||||
|
||||
import Button from './Element_button.svelte';
|
||||
import { msgs, user } from './Store_chat';
|
||||
export let layout = "";
|
||||
export let back = "";
|
||||
|
||||
@@ -24,7 +25,7 @@
|
||||
room_name: evt.target.innerText,
|
||||
}
|
||||
|
||||
const messages = fetch('/api/v2/chat/join',
|
||||
fetch('/api/v2/chat/join',
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -34,15 +35,8 @@
|
||||
.then(data =>
|
||||
{
|
||||
console.log(data);
|
||||
// data.messages.forEach(function(item) {
|
||||
// if (item.name === user.username) {
|
||||
// item.name = "me";
|
||||
// }
|
||||
// });
|
||||
// msgs.update(msgs => msgs.concat(data.messages));
|
||||
});
|
||||
|
||||
/*
|
||||
const messages = fetch('/api/v2/chat/messages')
|
||||
.then(resp => resp.json())
|
||||
.then(data =>
|
||||
@@ -53,9 +47,10 @@
|
||||
item.name = "me";
|
||||
}
|
||||
});
|
||||
msgs.update(msgs => msgs.concat(data.messages));
|
||||
msgs.update(msgs => msgs = data.messages);
|
||||
});
|
||||
layout = "room";
|
||||
/*
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user