Skip to content

Commit b648919

Browse files
committed
core: Add show_poll_vote method to Controller.
Creates an instance of PollResultsView class and shows the popup.
1 parent a9965b5 commit b648919

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

zulipterminal/core.py

+31
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
MarkdownHelpView,
4444
MsgInfoView,
4545
NoticeView,
46+
PollResultsView,
4647
PopUpConfirmationView,
4748
StreamInfoView,
4849
StreamMembersView,
@@ -281,6 +282,36 @@ def show_msg_info(
281282
)
282283
self.show_pop_up(msg_info_view, "area:msg")
283284

285+
def show_poll_vote(
286+
self,
287+
poll_question: str,
288+
options: Dict[str, Dict[str, Any]],
289+
) -> None:
290+
options_with_names = {}
291+
for option_key, option_data in options.items():
292+
option_text = option_data["option"]
293+
voter_ids = option_data["votes"]
294+
295+
voter_names = []
296+
for voter_id in voter_ids:
297+
user_info = self.model.get_user_info(voter_id)
298+
if user_info:
299+
voter_names.append(user_info["full_name"])
300+
301+
options_with_names[option_key] = {
302+
"option": option_text,
303+
"votes": voter_names if voter_names else [],
304+
}
305+
306+
self.show_pop_up(
307+
PollResultsView(
308+
self,
309+
poll_question,
310+
options_with_names,
311+
),
312+
"area:msg",
313+
)
314+
284315
def show_emoji_picker(self, message: Message) -> None:
285316
all_emoji_units = [
286317
(emoji_name, emoji["code"], emoji["aliases"])

0 commit comments

Comments
 (0)