proiect finalizat

This commit is contained in:
andrei-mihnea-cerbu
2024-01-13 12:59:19 +02:00
parent 54542da299
commit 67b7a241d7
53 changed files with 321 additions and 19 deletions
+13
View File
@@ -5,6 +5,10 @@ from app.views.message import MessageView
class ChatWindow(tk.Toplevel):
"""
This view is opened in a separate window and takes care of the communication between the two users. It receives
both the users' information and retrieves the conversation_url.
"""
def __init__(self, master=None, user_data=None, current_logged_user=None):
super().__init__(master)
@@ -48,6 +52,7 @@ class ChatWindow(tk.Toplevel):
}
def create_widgets(self, conversation):
"""Creates the UI of this view"""
# Create a frame for displaying messages
self.messages_frame = tk.Frame(self)
self.messages_frame.pack()
@@ -70,6 +75,10 @@ class ChatWindow(tk.Toplevel):
self.send_button.pack(side=tk.RIGHT)
def update_chat(self):
"""
This function is scheduled each second to make a request to the API to retrieve the latest chat between the
users
"""
self.messages_frame.destroy()
self.messages_frame = tk.Frame(self)
self.messages_frame.pack()
@@ -85,7 +94,9 @@ class ChatWindow(tk.Toplevel):
pass
def send_message(self):
"""At the submit button, the text is sent to the database"""
message = self.entry_widget.get()
self.define_send_message_params(message, "text")
if not message:
return
@@ -101,6 +112,7 @@ class ChatWindow(tk.Toplevel):
self.update_chat()
def get_conversation_url(self):
"""Fetches the conversation_url"""
request_builder.set_url(self.url)
request_builder.set_body(self.body)
request_builder.set_headers(self.headers)
@@ -113,6 +125,7 @@ class ChatWindow(tk.Toplevel):
return data['conversation_url']
def get_conversation(self):
"""Fetches the conversation between the users"""
request_builder.set_url(self.url)
request_builder.set_body(self.body)
request_builder.set_headers(self.headers)