Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Polls Widget on ZT. #1551

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 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,34 @@ 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]],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this is poll_options, this type is different again?

) -> 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:
voter_names.append(self.model.user_name_from_id(voter_id))

options_with_names[option_key] = {
"option": option_text,
"votes": voter_names if voter_names else [],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Is this conditional necessary?

}

self.show_pop_up(
PollResultsView(
self,
poll_question,
neiljp marked this conversation as resolved.
Show resolved Hide resolved
options_with_names,
),
"area:msg",
)

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