mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 23:24:01 +02:00
Fix reaction animations stopping after an hour uptime.
This commit is contained in:
parent
f909a36cbd
commit
cdf36cc387
2 changed files with 36 additions and 31 deletions
|
@ -279,38 +279,8 @@ void Reactions::request() {
|
||||||
MTP_int(_hash)
|
MTP_int(_hash)
|
||||||
)).done([=](const MTPmessages_AvailableReactions &result) {
|
)).done([=](const MTPmessages_AvailableReactions &result) {
|
||||||
_requestId = 0;
|
_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) {
|
result.match([&](const MTPDmessages_availableReactions &data) {
|
||||||
_hash = data.vhash().v;
|
updateFromData(data);
|
||||||
|
|
||||||
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({});
|
|
||||||
}, [&](const MTPDmessages_availableReactionsNotModified &) {
|
}, [&](const MTPDmessages_availableReactionsNotModified &) {
|
||||||
});
|
});
|
||||||
}).fail([=] {
|
}).fail([=] {
|
||||||
|
@ -319,6 +289,40 @@ void Reactions::request() {
|
||||||
}).send();
|
}).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) {
|
std::optional<Reaction> Reactions::parse(const MTPAvailableReaction &entry) {
|
||||||
return entry.match([&](const MTPDavailableReaction &data) {
|
return entry.match([&](const MTPDavailableReaction &data) {
|
||||||
const auto emoji = qs(data.vreaction());
|
const auto emoji = qs(data.vreaction());
|
||||||
|
|
|
@ -78,6 +78,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
void request();
|
void request();
|
||||||
|
void updateFromData(const MTPDmessages_availableReactions &data);
|
||||||
|
|
||||||
[[nodiscard]] std::optional<Reaction> parse(
|
[[nodiscard]] std::optional<Reaction> parse(
|
||||||
const MTPAvailableReaction &entry);
|
const MTPAvailableReaction &entry);
|
||||||
|
|
Loading…
Add table
Reference in a new issue