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,
|
self.room_group_name,
|
||||||
{
|
{
|
||||||
'type':'chat_message',
|
'type':'chat_message',
|
||||||
|
'username':self.scope["user"].username,
|
||||||
'message':message
|
'message':message
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
def chat_message(self, event):
|
def chat_message(self, event):
|
||||||
message = event['message']
|
|
||||||
|
|
||||||
self.send(text_data=json.dumps({
|
self.send(text_data=json.dumps({
|
||||||
'type':'chat',
|
'type':'chat',
|
||||||
'username':self.scope["user"].username,
|
'username':event['username'],
|
||||||
'message':message
|
'message':event['message']
|
||||||
}))
|
}))
|
||||||
|
@ -19,6 +19,7 @@ export default class extends AbstractView {
|
|||||||
|
|
||||||
let search = document.getElementById("form").value;
|
let search = document.getElementById("form").value;
|
||||||
|
|
||||||
|
let logged = client.isAuthentificate();
|
||||||
|
|
||||||
let users = await client.profiles.all();
|
let users = await client.profiles.all();
|
||||||
let list_users = document.getElementById('list_users');
|
let list_users = document.getElementById('list_users');
|
||||||
@ -32,6 +33,15 @@ export default class extends AbstractView {
|
|||||||
username.href = `/profiles/${user.user_id}`;
|
username.href = `/profiles/${user.user_id}`;
|
||||||
username.appendChild(document.createTextNode(user.username));
|
username.appendChild(document.createTextNode(user.username));
|
||||||
new_user.appendChild(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
|
// break line
|
||||||
new_user.appendChild(document.createElement("br"));
|
new_user.appendChild(document.createElement("br"));
|
||||||
@ -41,6 +51,7 @@ export default class extends AbstractView {
|
|||||||
img.src = user.avatar_url;
|
img.src = user.avatar_url;
|
||||||
new_user.appendChild(img);
|
new_user.appendChild(img);
|
||||||
|
|
||||||
|
|
||||||
list_users.appendChild(new_user);
|
list_users.appendChild(new_user);
|
||||||
});
|
});
|
||||||
console.log(list_users);
|
console.log(list_users);
|
||||||
|
Loading…
Reference in New Issue
Block a user