@@ -65,6 +65,7 @@ def __init__(self, message: Message, model: "Model", last_message: Any) -> None:
65
65
self .topic_links : Dict [str , Tuple [str , int , bool ]] = dict ()
66
66
self .time_mentions : List [Tuple [str , str ]] = list ()
67
67
self .last_message = last_message
68
+ self .widget_type : str = ""
68
69
# if this is the first message
69
70
if self .last_message is None :
70
71
self .last_message = defaultdict (dict )
@@ -731,26 +732,26 @@ def main_view(self) -> List[Any]:
731
732
)
732
733
733
734
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" ))
735
736
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 (
738
739
self .message .get ("submessages" )
739
740
)
740
741
741
742
poll_widget = (
742
- f"<strong>Poll: { poll_question } </strong>"
743
- if poll_question
743
+ f"<strong>Poll: { self . poll_question } </strong>"
744
+ if self . poll_question
744
745
else "No poll question provided. Please add one via the web app."
745
746
)
746
747
747
- if poll_options :
748
+ if self . poll_options :
748
749
max_votes_len = max (
749
750
len (str (len (option ["votes" ])))
750
- for option in poll_options .values ()
751
+ for option in self . poll_options .values ()
751
752
)
752
753
753
- for option_info in poll_options .values ():
754
+ for option_info in self . poll_options .values ():
754
755
padded_votes = f"{ len (option_info ['votes' ]):>{max_votes_len }} "
755
756
poll_widget += f"\n [ { padded_votes } ] { option_info ['option' ]} "
756
757
else :
@@ -1157,4 +1158,6 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
1157
1158
self .model .controller .show_emoji_picker (self .message )
1158
1159
elif is_command_key ("MSG_SENDER_INFO" , key ):
1159
1160
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 )
1160
1163
return key
0 commit comments