Skip to content

Commit ac81d5c

Browse files
committed
messages: Process todo widgets.
Implement logic to display processed todo widgets in ZT.
1 parent dcf4492 commit ac81d5c

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

zulipterminal/ui_tools/messages.py

+25-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from zulipterminal.server_url import near_message_url
3434
from zulipterminal.ui_tools.tables import render_table
3535
from zulipterminal.urwid_types import urwid_MarkupTuple, urwid_Size
36-
from zulipterminal.widget import find_widget_type
36+
from zulipterminal.widget import find_widget_type, process_todo_widget
3737

3838

3939
if typing.TYPE_CHECKING:
@@ -731,9 +731,30 @@ def main_view(self) -> List[Any]:
731731
)
732732

733733
if self.message.get("submessages"):
734-
widget_type = find_widget_type(
735-
self.message.get("submessages")
736-
) # noqa: F841
734+
widget_type = find_widget_type(self.message.get("submessages"))
735+
736+
if widget_type == "todo":
737+
title, tasks = process_todo_widget(self.message.get("submessages"))
738+
739+
todo_widget = f"<strong>{title}</strong>"
740+
741+
if tasks:
742+
for task_id, task_info in tasks.items():
743+
task_status = "[✔ ]" if task_info["completed"] else "[ ]"
744+
task_name = task_info["task"]
745+
task_description = task_info["desc"]
746+
747+
if task_description == "":
748+
todo_widget += (
749+
f"\n{task_status} <strong>{task_name}</strong>"
750+
)
751+
else:
752+
todo_widget += (
753+
f"\n{task_status} <strong>{task_name}</strong>: "
754+
f"{task_description}"
755+
)
756+
757+
self.message["content"] = todo_widget
737758

738759
# Transform raw message content into markup (As needed by urwid.Text)
739760
content, self.message_links, self.time_mentions = self.transform_content(

0 commit comments

Comments
 (0)