From 4ebf6ebb6f188b00a838a3b6337887e76c308c3d Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 12 Mar 2019 13:15:08 +0400 Subject: [PATCH] Use the same poll option values as others. --- Telegram/SourceFiles/boxes/create_poll_box.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/boxes/create_poll_box.cpp b/Telegram/SourceFiles/boxes/create_poll_box.cpp index 65c05109e0..fcd3a9a616 100644 --- a/Telegram/SourceFiles/boxes/create_poll_box.cpp +++ b/Telegram/SourceFiles/boxes/create_poll_box.cpp @@ -75,7 +75,7 @@ private: not_null field() const; - [[nodiscard]] PollAnswer toPollAnswer(char id) const; + [[nodiscard]] PollAnswer toPollAnswer(int index) const; [[nodiscard]] rpl::producer removeClicks() const; @@ -324,10 +324,12 @@ void Options::Option::removePlaceholder() const { field()->setPlaceholder(nullptr); } -PollAnswer Options::Option::toPollAnswer(char id) const { +PollAnswer Options::Option::toPollAnswer(int index) const { + Expects(index >= 0 && index < kMaxOptionsCount); + return PollAnswer{ field()->getLastText().trimmed(), - QByteArray(1, id) + QByteArray(1, ('0' + index)) }; } @@ -388,9 +390,9 @@ void Options::Option::destroy(FnMut done) { std::vector Options::toPollAnswers() const { auto result = std::vector(); result.reserve(_list.size()); - auto counter = char(0); + auto counter = int(0); const auto makeAnswer = [&](const Option &option) { - return option.toPollAnswer(++counter); + return option.toPollAnswer(counter++); }; ranges::copy( _list