From 360ff0058d69f740bf8742e87008efa2d6b59c0a Mon Sep 17 00:00:00 2001 From: hyperbel Date: Mon, 17 Jul 2023 19:29:38 +0200 Subject: [PATCH] render messages correctly --- party/chat.py | 6 ++++-- party/static/js/chat.js | 7 ++++--- party/templates/session.html | 29 +++++++++++++++-------------- scripts/generate_mock_messages.py | 16 +++++++++++++--- 4 files changed, 36 insertions(+), 22 deletions(-) diff --git a/party/chat.py b/party/chat.py index 78190f3..e47461d 100644 --- a/party/chat.py +++ b/party/chat.py @@ -16,8 +16,9 @@ class Chat: @classmethod def getAllMessages(self)-> list[dict]: - return list(self.collection.find()) - + messages = self.collection.find() + print(messages) + return list(messages) @classmethod def insertMessage(self, content: str, author: str, timestamp: str): @@ -37,5 +38,6 @@ class Chat: 'author': author, 'timestamp': timestamp, } + print(message) return message diff --git a/party/static/js/chat.js b/party/static/js/chat.js index 5bfea43..a93ae64 100644 --- a/party/static/js/chat.js +++ b/party/static/js/chat.js @@ -6,7 +6,8 @@ function getNChatMessages(socket, count, skip) { data = JSON.parse(data.data.messages) for (let message of data) { - message_array.push(buildChatMessage(message.content, message.author, message.timestamp)); + console.log(message) + message_array.push(buildChatMessage(message.sender, message.text, message.timestamp['$date'])); } const chatBox = document.getElementById('chatBox'); @@ -17,8 +18,8 @@ function getNChatMessages(socket, count, skip) { }); } -function buildChatMessage(content, author, timestap) { - console.log(content, author, timestap); +function buildChatMessage(author, content, timestap) { + //console.log(content, author, timestap); const message = document.createElement('div'); message.classList.add('chat-message'); diff --git a/party/templates/session.html b/party/templates/session.html index 59b6ae9..9a08d95 100644 --- a/party/templates/session.html +++ b/party/templates/session.html @@ -53,20 +53,21 @@

Planer

- - - - - - - - - - - - - -
EventZeitStatusVerwalten
fff
+ + + Event + Zeit + Status + Verwalten + + + f + f + f + + + +