2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 22:16:14 +00:00

Add create poll box from groups three-dot menu.

This commit is contained in:
John Preston
2018-12-20 20:02:44 +04:00
parent 74c1db740d
commit b6f7832745
15 changed files with 752 additions and 52 deletions

View File

@@ -125,3 +125,22 @@ bool PollData::applyResultToAnswers(
bool PollData::voted() const {
return ranges::find(answers, true, &PollAnswer::chosen) != end(answers);
}
MTPPoll PollDataToMTP(not_null<const PollData*> poll) {
const auto convert = [](const PollAnswer &answer) {
return MTP_pollAnswer(
MTP_string(answer.text),
MTP_bytes(answer.option));
};
auto answers = QVector<MTPPollAnswer>();
answers.reserve(poll->answers.size());
ranges::transform(
poll->answers,
ranges::back_inserter(answers),
convert);
return MTP_poll(
MTP_long(poll->id),
MTP_flags(MTPDpoll::Flag::f_closed),
MTP_string(poll->question),
MTP_vector<MTPPollAnswer>(answers));
}

View File

@@ -48,3 +48,5 @@ private:
bool isMinResults);
};
MTPPoll PollDataToMTP(not_null<const PollData*> poll);