diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index dbe71f0bb..79ea526b9 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -192,8 +192,9 @@ maskPointChin = MaskPoint; maskPosition point:MaskPoint x_shift:double y_shift:double scale:double = MaskPosition; -//@description Describes one answer option of a poll @text Option text, 1-100 characters @voter_count Number of voters for this option, available only for closed or voted polls @vote_percentage The percentage of votes for this option, 0-100 @is_chosen True, if the option was chosen by the user -pollOption text:string voter_count:int32 vote_percentage:int32 is_chosen:Bool = PollOption; +//@description Describes one answer option of a poll @text Option text, 1-100 characters @voter_count Number of voters for this option, available only for closed or voted polls @vote_percentage The percentage of votes for this option, 0-100 +//@is_chosen True, if the option was chosen by the user @is_being_chosen True, if the option is being chosen by a pending setPollAnswer request +pollOption text:string voter_count:int32 vote_percentage:int32 is_chosen:Bool is_being_chosen:Bool = PollOption; //@description Describes an animation file. The animation must be encoded in GIF or MPEG4 format @duration Duration of the animation, in seconds; as defined by the sender @width Width of the animation @height Height of the animation diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 470b3af4f..f76fa13d4 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/PollManager.cpp b/td/telegram/PollManager.cpp index 86ec48231..e50189c1c 100644 --- a/td/telegram/PollManager.cpp +++ b/td/telegram/PollManager.cpp @@ -309,7 +309,8 @@ PollManager::Poll *PollManager::get_poll_force(PollId poll_id) { } td_api::object_ptr PollManager::get_poll_option_object(const PollOption &poll_option) { - return td_api::make_object(poll_option.text, poll_option.voter_count, 0, poll_option.is_chosen); + return td_api::make_object(poll_option.text, poll_option.voter_count, 0, poll_option.is_chosen, + false); } vector PollManager::get_vote_percentage(const vector &voter_counts, int32 total_voter_count) { @@ -420,18 +421,14 @@ td_api::object_ptr PollManager::get_poll_object(PollId poll_id) co } else { auto &chosen_options = it->second.options_; for (auto &poll_option : poll->options) { - auto is_chosen = + auto is_being_chosen = std::find(chosen_options.begin(), chosen_options.end(), poll_option.data) != chosen_options.end(); if (poll_option.is_chosen) { voter_count_diff = -1; } poll_options.push_back(td_api::make_object( - poll_option.text, - poll_option.voter_count - static_cast(poll_option.is_chosen) + static_cast(is_chosen), 0, - is_chosen)); - } - if (!chosen_options.empty()) { - voter_count_diff++; + poll_option.text, poll_option.voter_count - static_cast(poll_option.is_chosen), 0, false, + is_being_chosen)); } }