@@ -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,24 +760,24 @@ 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
767
768
poll_widget = (
768
- f"<strong>Poll\n { poll_question } </strong>"
769
- if poll_question
769
+ f"<strong>Poll\n { self . poll_question } </strong>"
770
+ if self . poll_question
770
771
else "No poll question provided. Please add one via the web app."
771
772
)
772
773
773
- if poll_options :
774
+ if self . poll_options :
774
775
max_votes_len = max (
775
776
len (str (len (option ["votes" ])))
776
- for option in poll_options .values ()
777
+ for option in self . poll_options .values ()
777
778
)
778
779
779
- for option_info in poll_options .values ():
780
+ for option_info in self . poll_options .values ():
780
781
padded_votes = f"{ len (option_info ['votes' ]):>{max_votes_len }} "
781
782
poll_widget += f"\n [ { padded_votes } ] { option_info ['option' ]} "
782
783
else :
@@ -1185,4 +1186,6 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
1185
1186
self .model .controller .show_emoji_picker (self .message )
1186
1187
elif is_command_key ("MSG_SENDER_INFO" , key ):
1187
1188
self .model .controller .show_msg_sender_info (self .message ["sender_id" ])
1189
+ elif is_command_key ("SHOW_POLL_VOTES" , key ) and self .widget_type == "poll" :
1190
+ self .model .controller .show_poll_vote (self .poll_question , self .poll_options )
1188
1191
return key
0 commit comments