Fix reaction animations stopping after an hour uptime.
This commit is contained in:
parent
f909a36cbd
commit
cdf36cc387
|
@ -279,38 +279,8 @@ void Reactions::request() {
|
|||
MTP_int(_hash)
|
||||
)).done([=](const MTPmessages_AvailableReactions &result) {
|
||||
_requestId = 0;
|
||||
const auto oldCache = base::take(_iconsCache);
|
||||
const auto toCache = [&](DocumentData *document) {
|
||||
if (document) {
|
||||
_iconsCache.emplace(document, document->createMediaView());
|
||||
}
|
||||
};
|
||||
result.match([&](const MTPDmessages_availableReactions &data) {
|
||||
_hash = data.vhash().v;
|
||||
|
||||
const auto &list = data.vreactions().v;
|
||||
_active.clear();
|
||||
_available.clear();
|
||||
_active.reserve(list.size());
|
||||
_available.reserve(list.size());
|
||||
_iconsCache.reserve(list.size() * 2);
|
||||
for (const auto &reaction : list) {
|
||||
if (const auto parsed = parse(reaction)) {
|
||||
_available.push_back(*parsed);
|
||||
if (parsed->active) {
|
||||
_active.push_back(*parsed);
|
||||
toCache(parsed->appearAnimation);
|
||||
toCache(parsed->selectAnimation);
|
||||
toCache(parsed->centerIcon);
|
||||
toCache(parsed->aroundAnimation);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_waitingForList) {
|
||||
_waitingForList = false;
|
||||
resolveImages();
|
||||
}
|
||||
_updated.fire({});
|
||||
updateFromData(data);
|
||||
}, [&](const MTPDmessages_availableReactionsNotModified &) {
|
||||
});
|
||||
}).fail([=] {
|
||||
|
@ -319,6 +289,40 @@ void Reactions::request() {
|
|||
}).send();
|
||||
}
|
||||
|
||||
void Reactions::updateFromData(const MTPDmessages_availableReactions &data) {
|
||||
_hash = data.vhash().v;
|
||||
|
||||
const auto &list = data.vreactions().v;
|
||||
const auto oldCache = base::take(_iconsCache);
|
||||
const auto toCache = [&](DocumentData *document) {
|
||||
if (document) {
|
||||
_iconsCache.emplace(document, document->createMediaView());
|
||||
}
|
||||
};
|
||||
_active.clear();
|
||||
_available.clear();
|
||||
_active.reserve(list.size());
|
||||
_available.reserve(list.size());
|
||||
_iconsCache.reserve(list.size() * 4);
|
||||
for (const auto &reaction : list) {
|
||||
if (const auto parsed = parse(reaction)) {
|
||||
_available.push_back(*parsed);
|
||||
if (parsed->active) {
|
||||
_active.push_back(*parsed);
|
||||
toCache(parsed->appearAnimation);
|
||||
toCache(parsed->selectAnimation);
|
||||
toCache(parsed->centerIcon);
|
||||
toCache(parsed->aroundAnimation);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_waitingForList) {
|
||||
_waitingForList = false;
|
||||
resolveImages();
|
||||
}
|
||||
_updated.fire({});
|
||||
}
|
||||
|
||||
std::optional<Reaction> Reactions::parse(const MTPAvailableReaction &entry) {
|
||||
return entry.match([&](const MTPDavailableReaction &data) {
|
||||
const auto emoji = qs(data.vreaction());
|
||||
|
|
|
@ -78,6 +78,7 @@ private:
|
|||
};
|
||||
|
||||
void request();
|
||||
void updateFromData(const MTPDmessages_availableReactions &data);
|
||||
|
||||
[[nodiscard]] std::optional<Reaction> parse(
|
||||
const MTPAvailableReaction &entry);
|
||||
|
|
Loading…
Reference in New Issue