@@ -69,6 +69,7 @@ def __init__(self, message: Message, model: "Model", last_message: Any) -> None:
69
69
self .topic_links : Dict [str , Tuple [str , int , bool ]] = dict ()
70
70
self .time_mentions : List [Tuple [str , str ]] = list ()
71
71
self .last_message = last_message
72
+ self .widget_type : str = ""
72
73
# if this is the first message
73
74
if self .last_message is None :
74
75
self .last_message = defaultdict (dict )
@@ -735,9 +736,9 @@ def main_view(self) -> List[Any]:
735
736
)
736
737
737
738
if self .message .get ("submessages" ):
738
- widget_type = find_widget_type (self .message .get ("submessages" , []))
739
+ self . widget_type = find_widget_type (self .message .get ("submessages" , []))
739
740
740
- if widget_type == "todo" :
741
+ if self . widget_type == "todo" :
741
742
title , tasks = process_todo_widget (self .message .get ("submessages" , []))
742
743
743
744
todo_widget = "<strong>To-do</strong>\n " + f"<strong>{ title } </strong>"
@@ -759,8 +760,8 @@ def main_view(self) -> List[Any]:
759
760
# though it's not very useful.
760
761
self .message ["content" ] = todo_widget
761
762
762
- elif widget_type == "poll" :
763
- poll_question , poll_options = process_poll_widget (
763
+ elif self . widget_type == "poll" :
764
+ self . poll_question , self . poll_options = process_poll_widget (
764
765
self .message .get ("submessages" , [])
765
766
)
766
767
@@ -774,13 +775,13 @@ def main_view(self) -> List[Any]:
774
775
775
776
poll_widget = f"<strong>Poll\n { poll_question } </strong>"
776
777
777
- if poll_options :
778
+ if self . poll_options :
778
779
max_votes_len = max (
779
780
len (str (len (option ["votes" ])))
780
- for option in poll_options .values ()
781
+ for option in self . poll_options .values ()
781
782
)
782
783
783
- for option_info in poll_options .values ():
784
+ for option_info in self . poll_options .values ():
784
785
padded_votes = f"{ len (option_info ['votes' ]):>{max_votes_len }} "
785
786
poll_widget += f"\n [ { padded_votes } ] { option_info ['option' ]} "
786
787
else :
@@ -1189,4 +1190,6 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
1189
1190
self .model .controller .show_emoji_picker (self .message )
1190
1191
elif is_command_key ("MSG_SENDER_INFO" , key ):
1191
1192
self .model .controller .show_msg_sender_info (self .message ["sender_id" ])
1193
+ elif is_command_key ("SHOW_POLL_VOTES" , key ) and self .widget_type == "poll" :
1194
+ self .model .controller .show_poll_vote (self .poll_question , self .poll_options )
1192
1195
return key
0 commit comments