Skip to content

Commit

Permalink
core: Add show_poll_vote method to Controller.
Browse files Browse the repository at this point in the history
Creates an instance of PollResultsView class and shows the popup.
  • Loading branch information
rsashank committed Oct 12, 2024
1 parent a9965b5 commit b648919
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions zulipterminal/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
MarkdownHelpView,
MsgInfoView,
NoticeView,
PollResultsView,
PopUpConfirmationView,
StreamInfoView,
StreamMembersView,
Expand Down Expand Up @@ -281,6 +282,36 @@ def show_msg_info(
)
self.show_pop_up(msg_info_view, "area:msg")

def show_poll_vote(
self,
poll_question: str,
options: Dict[str, Dict[str, Any]],
) -> None:
options_with_names = {}
for option_key, option_data in options.items():
option_text = option_data["option"]
voter_ids = option_data["votes"]

voter_names = []
for voter_id in voter_ids:
user_info = self.model.get_user_info(voter_id)
if user_info:
voter_names.append(user_info["full_name"])

options_with_names[option_key] = {
"option": option_text,
"votes": voter_names if voter_names else [],
}

self.show_pop_up(
PollResultsView(
self,
poll_question,
options_with_names,
),
"area:msg",
)

def show_emoji_picker(self, message: Message) -> None:
all_emoji_units = [
(emoji_name, emoji["code"], emoji["aliases"])
Expand Down

0 comments on commit b648919

Please sign in to comment.