mirror of https://github.com/procxx/kepka.git
Force reload results on auto-closed quiz.
This commit is contained in:
parent
b34d5b8306
commit
5dcb232b77
|
@ -48,6 +48,7 @@ bool PollData::closeByTimer() {
|
|||
return false;
|
||||
}
|
||||
_flags |= Flag::Closed;
|
||||
_lastResultsUpdate = -1; // Force reload results.
|
||||
++version;
|
||||
return true;
|
||||
}
|
||||
|
@ -105,7 +106,7 @@ bool PollData::applyChanges(const MTPDpoll &poll) {
|
|||
|
||||
bool PollData::applyResults(const MTPPollResults &results) {
|
||||
return results.match([&](const MTPDpollResults &results) {
|
||||
lastResultsUpdate = crl::now();
|
||||
_lastResultsUpdate = crl::now();
|
||||
|
||||
const auto newTotalVoters =
|
||||
results.vtotal_voters().value_or(totalVoters);
|
||||
|
@ -158,13 +159,16 @@ bool PollData::applyResults(const MTPPollResults &results) {
|
|||
});
|
||||
}
|
||||
|
||||
void PollData::checkResultsReload(not_null<HistoryItem*> item, crl::time now) {
|
||||
if (lastResultsUpdate && lastResultsUpdate + kShortPollTimeout > now) {
|
||||
void PollData::checkResultsReload(
|
||||
not_null<HistoryItem*> item,
|
||||
crl::time now) {
|
||||
if (_lastResultsUpdate > 0
|
||||
&& _lastResultsUpdate + kShortPollTimeout > now) {
|
||||
return;
|
||||
} else if (closed()) {
|
||||
} else if (closed() && _lastResultsUpdate >= 0) {
|
||||
return;
|
||||
}
|
||||
lastResultsUpdate = now;
|
||||
_lastResultsUpdate = now;
|
||||
_owner->session().api().reloadPollResults(item);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@ struct PollData {
|
|||
std::vector<PollAnswer> answers;
|
||||
std::vector<not_null<UserData*>> recentVoters;
|
||||
std::vector<QByteArray> sendingVotes;
|
||||
crl::time lastResultsUpdate = 0;
|
||||
TextWithEntities solution;
|
||||
TimeId closePeriod = 0;
|
||||
TimeId closeDate = 0;
|
||||
|
@ -76,8 +75,9 @@ private:
|
|||
const MTPPollAnswerVoters &result,
|
||||
bool isMinResults);
|
||||
|
||||
not_null<Data::Session*> _owner;
|
||||
const not_null<Data::Session*> _owner;
|
||||
Flags _flags = Flags();
|
||||
crl::time _lastResultsUpdate = 0; // < 0 means force reload.
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue