2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Keep reaction media in memory.

This commit is contained in:
John Preston
2022-01-07 16:19:43 +03:00
parent f98c08f4c6
commit c2c7a25487
3 changed files with 13 additions and 1 deletions

View File

@@ -231,15 +231,22 @@ void Reactions::request() {
_hash = data.vhash().v;
const auto &list = data.vreactions().v;
const auto oldCache = base::take(_iconsCache);
_active.clear();
_available.clear();
_active.reserve(list.size());
_available.reserve(list.size());
_iconsCache.reserve(list.size() * 2);
const auto toCache = [&](not_null<DocumentData*> document) {
_iconsCache.emplace(document, document->createMediaView());
};
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);
}
}
}