Skip to content

Commit

Permalink
messages: Process todo widgets.
Browse files Browse the repository at this point in the history
Implement logic to display processed todo widgets in ZT.
  • Loading branch information
rsashank committed Oct 4, 2024
1 parent 8f6ccbc commit 314fa0d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion zulipterminal/ui_tools/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"<strong>{title}</strong>"

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} <strong>{task_name}</strong>"
else:
todo_widget += f"\n{status} <strong>{task_name}</strong>: {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
Expand Down

0 comments on commit 314fa0d

Please sign in to comment.