Simplest poll layout.

This commit is contained in:
John Preston
2018-12-18 17:56:38 +04:00
parent b0d01389c6
commit 4bb5dcf50c
13 changed files with 374 additions and 31 deletions
+9 -15
View File
@@ -1529,22 +1529,16 @@ not_null<PollData*> Session::poll(const MTPDmessageMediaPoll &data) {
}
void Session::applyPollUpdate(const MTPDupdateMessagePoll &update) {
const auto poll = [&] {
if (update.has_poll()) {
return update.vpoll.match([&](const MTPDpoll &data) {
const auto i = _polls.find(data.vid.v);
return (i != end(_polls)) ? i->second.get() : nullptr;
});
}
const auto item = App::histItemById(
peerToChannel(peerFromMTP(update.vpeer)),
update.vmsg_id.v);
return (item && item->media())
? item->media()->poll()
: nullptr;
const auto updated = [&] {
const auto i = _polls.find(update.vpoll_id.v);
return (i == end(_polls))
? nullptr
: update.has_poll()
? poll(update.vpoll).get()
: i->second.get();
}();
if (poll && poll->applyResults(update.vresults)) {
requestPollViewRepaint(poll);
if (updated && updated->applyResults(update.vresults)) {
requestPollViewRepaint(updated);
}
}