From 314fa0d3f02bd0cc4c62b2094ea7febc416d9e3a Mon Sep 17 00:00:00 2001 From: rsashank Date: Fri, 4 Oct 2024 09:52:41 +0530 Subject: [PATCH] messages: Process todo widgets. Implement logic to display processed todo widgets in ZT. --- zulipterminal/ui_tools/messages.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/zulipterminal/ui_tools/messages.py b/zulipterminal/ui_tools/messages.py index 2e5742a065..bf128dcc29 100644 --- a/zulipterminal/ui_tools/messages.py +++ b/zulipterminal/ui_tools/messages.py @@ -33,7 +33,7 @@ from zulipterminal.server_url import near_message_url from zulipterminal.ui_tools.tables import render_table from zulipterminal.urwid_types import urwid_MarkupTuple, urwid_Size -from zulipterminal.widget import find_widget_type +from zulipterminal.widget import find_widget_type, process_todo_widget if typing.TYPE_CHECKING: @@ -733,6 +733,24 @@ def main_view(self) -> List[Any]: if self.message.get("submessages"): widget_type = find_widget_type(self.message.get("submessages")) + if widget_type == "todo": + title, tasks = process_todo_widget(self.message.get("submessages")) + + todo_widget = f"{title}" + + if tasks: + for task_id, task_info in tasks.items(): + status = "[✔ ]" if task_info["completed"] else "[ ]" + task_name = task_info["task"] + task_description = task_info["desc"] + + if task_description == "": + todo_widget += f"\n{status} {task_name}" + else: + todo_widget += f"\n{status} {task_name}: {task_description}" + + self.message["content"] = todo_widget + # Transform raw message content into markup (As needed by urwid.Text) content, self.message_links, self.time_mentions = self.transform_content( self.message["content"], self.model.server_url