@@ -65,6 +65,7 @@ def __init__(self, message: Message, model: "Model", last_message: Any) -> None:
6565        self .topic_links : Dict [str , Tuple [str , int , bool ]] =  dict ()
6666        self .time_mentions : List [Tuple [str , str ]] =  list ()
6767        self .last_message  =  last_message 
68+         self .widget_type : str  =  "" 
6869        # if this is the first message 
6970        if  self .last_message  is  None :
7071            self .last_message  =  defaultdict (dict )
@@ -731,26 +732,26 @@ def main_view(self) -> List[Any]:
731732            )
732733
733734        if  self .message .get ("submessages" ):
734-             widget_type  =  find_widget_type (self .message .get ("submessages" ))
735+             self . widget_type  =  find_widget_type (self .message .get ("submessages" ))
735736
736-             if  widget_type  ==  "poll" :
737-                 poll_question , poll_options  =  process_poll_widget (
737+             if  self . widget_type  ==  "poll" :
738+                 self . poll_question , self . poll_options  =  process_poll_widget (
738739                    self .message .get ("submessages" )
739740                )
740741
741742                poll_widget  =  (
742-                     f"<strong>Poll: { poll_question }  
743-                     if  poll_question 
743+                     f"<strong>Poll: { self . poll_question }  
744+                     if  self . poll_question 
744745                    else  "No poll question provided. Please add one via the web app." 
745746                )
746747
747-                 if  poll_options :
748+                 if  self . poll_options :
748749                    max_votes_len  =  max (
749750                        len (str (len (option ["votes" ])))
750-                         for  option  in  poll_options .values ()
751+                         for  option  in  self . poll_options .values ()
751752                    )
752753
753-                     for  option_info  in  poll_options .values ():
754+                     for  option_info  in  self . poll_options .values ():
754755                        padded_votes  =  f"{ len (option_info ['votes' ]):>{max_votes_len }}  
755756                        poll_widget  +=  f"\n [ { padded_votes } { option_info ['option' ]}  
756757                else :
@@ -1157,4 +1158,6 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
11571158            self .model .controller .show_emoji_picker (self .message )
11581159        elif  is_command_key ("MSG_SENDER_INFO" , key ):
11591160            self .model .controller .show_msg_sender_info (self .message ["sender_id" ])
1161+         elif  is_command_key ("SHOW_POLL_VOTES" , key ) and  self .widget_type  ==  "poll" :
1162+             self .model .controller .show_poll_vote (self .poll_question , self .poll_options )
11601163        return  key 
0 commit comments