@@ -69,6 +69,7 @@ def __init__(self, message: Message, model: "Model", last_message: Any) -> None:
6969 self .topic_links : Dict [str , Tuple [str , int , bool ]] = dict ()
7070 self .time_mentions : List [Tuple [str , str ]] = list ()
7171 self .last_message = last_message
72+ self .widget_type : str = ""
7273 # if this is the first message
7374 if self .last_message is None :
7475 self .last_message = defaultdict (dict )
@@ -735,9 +736,9 @@ def main_view(self) -> List[Any]:
735736 )
736737
737738 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" , []))
739740
740- if widget_type == "todo" :
741+ if self . widget_type == "todo" :
741742 title , tasks = process_todo_widget (self .message .get ("submessages" , []))
742743
743744 todo_widget = "<strong>To-do</strong>\n " + f"<strong>{ title } </strong>"
@@ -759,24 +760,24 @@ def main_view(self) -> List[Any]:
759760 # though it's not very useful.
760761 self .message ["content" ] = todo_widget
761762
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 (
764765 self .message .get ("submessages" , [])
765766 )
766767
767768 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
770771 else "No poll question provided. Please add one via the web app."
771772 )
772773
773- if poll_options :
774+ if self . poll_options :
774775 max_votes_len = max (
775776 len (str (len (option ["votes" ])))
776- for option in poll_options .values ()
777+ for option in self . poll_options .values ()
777778 )
778779
779- for option_info in poll_options .values ():
780+ for option_info in self . poll_options .values ():
780781 padded_votes = f"{ len (option_info ['votes' ]):>{max_votes_len }} "
781782 poll_widget += f"\n [ { padded_votes } ] { option_info ['option' ]} "
782783 else :
@@ -1185,4 +1186,6 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
11851186 self .model .controller .show_emoji_picker (self .message )
11861187 elif is_command_key ("MSG_SENDER_INFO" , key ):
11871188 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 )
11881191 return key
0 commit comments