proiect finalizat
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user