|
33 | 33 | from zulipterminal.server_url import near_message_url
|
34 | 34 | from zulipterminal.ui_tools.tables import render_table
|
35 | 35 | from zulipterminal.urwid_types import urwid_MarkupTuple, urwid_Size
|
| 36 | +from zulipterminal.widget import find_widget_type, process_todo_widget |
36 | 37 |
|
37 | 38 |
|
38 | 39 | if typing.TYPE_CHECKING:
|
@@ -729,6 +730,31 @@ def main_view(self) -> List[Any]:
|
729 | 730 | "/me", f"<strong>{self.message['sender_full_name']}</strong>", 1
|
730 | 731 | )
|
731 | 732 |
|
| 733 | + if self.message.get("submessages"): |
| 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 = "<strong>To-do</strong>\n" + 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 | + todo_widget += f"\n{task_status} <strong>{task_name}</strong>" |
| 748 | + |
| 749 | + if task_description: |
| 750 | + todo_widget += f": {task_description}" |
| 751 | + |
| 752 | + # Update the message content with the latest todo_widget, |
| 753 | + # generated from submessages to reflect the current state. |
| 754 | + # The original raw content can be fetched if needed, |
| 755 | + # though it's not very useful. |
| 756 | + self.message["content"] = todo_widget |
| 757 | + |
732 | 758 | # Transform raw message content into markup (As needed by urwid.Text)
|
733 | 759 | content, self.message_links, self.time_mentions = self.transform_content(
|
734 | 760 | self.message["content"], self.model.server_url
|
|
0 commit comments