Bug fix with username in chat
This commit is contained in:
parent
624fb47e04
commit
78379aea1b
@ -22,15 +22,15 @@ class ChatConsumer(WebsocketConsumer):
|
||||
self.room_group_name,
|
||||
{
|
||||
'type':'chat_message',
|
||||
'username':self.scope["user"].username,
|
||||
'message':message
|
||||
}
|
||||
)
|
||||
|
||||
def chat_message(self, event):
|
||||
message = event['message']
|
||||
|
||||
self.send(text_data=json.dumps({
|
||||
'type':'chat',
|
||||
'username':self.scope["user"].username,
|
||||
'message':message
|
||||
'username':event['username'],
|
||||
'message':event['message']
|
||||
}))
|
||||
|
@ -19,6 +19,7 @@ export default class extends AbstractView {
|
||||
|
||||
let search = document.getElementById("form").value;
|
||||
|
||||
let logged = client.isAuthentificate();
|
||||
|
||||
let users = await client.profiles.all();
|
||||
let list_users = document.getElementById('list_users');
|
||||
@ -32,6 +33,15 @@ export default class extends AbstractView {
|
||||
username.href = `/profiles/${user.user_id}`;
|
||||
username.appendChild(document.createTextNode(user.username));
|
||||
new_user.appendChild(username);
|
||||
|
||||
// space
|
||||
new_user.appendChild(document.createTextNode(" "));
|
||||
|
||||
// chat
|
||||
let chat = document.createElement("a");
|
||||
chat.href = `/chat`
|
||||
chat.appendChild(document.createTextNode("Chat"));
|
||||
new_user.appendChild(chat);
|
||||
|
||||
// break line
|
||||
new_user.appendChild(document.createElement("br"));
|
||||
@ -41,6 +51,7 @@ export default class extends AbstractView {
|
||||
img.src = user.avatar_url;
|
||||
new_user.appendChild(img);
|
||||
|
||||
|
||||
list_users.appendChild(new_user);
|
||||
});
|
||||
console.log(list_users);
|
||||
|
Loading…
Reference in New Issue
Block a user