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

Request and cache featured emoji sets.

This commit is contained in:
John Preston
2022-07-22 16:08:10 +03:00
parent b31a3ba5a3
commit b4b55973b5
10 changed files with 185 additions and 70 deletions

View File

@@ -60,6 +60,23 @@ namespace {
: 0;
}
[[nodiscard]] uint64 CountFeaturedHash(
not_null<Main::Session*> session,
const Data::StickersSetsOrder &order) {
auto result = HashInit();
const auto &sets = session->data().stickers().sets();
for (const auto setId : order) {
HashUpdate(result, setId);
const auto it = sets.find(setId);
if (it != sets.cend()
&& (it->second->flags & Data::StickersSetFlag::Unread)) {
HashUpdate(result, 1);
}
}
return HashFinalize(result);
}
} // namespace
uint64 CountStickersHash(
@@ -104,19 +121,15 @@ uint64 CountFavedStickersHash(not_null<Main::Session*> session) {
}
uint64 CountFeaturedStickersHash(not_null<Main::Session*> session) {
auto result = HashInit();
const auto &sets = session->data().stickers().sets();
const auto &featured = session->data().stickers().featuredSetsOrder();
for (const auto setId : featured) {
HashUpdate(result, setId);
return CountFeaturedHash(
session,
session->data().stickers().featuredSetsOrder());
}
const auto it = sets.find(setId);
if (it != sets.cend()
&& (it->second->flags & Data::StickersSetFlag::Unread)) {
HashUpdate(result, 1);
}
}
return HashFinalize(result);
uint64 CountFeaturedEmojiHash(not_null<Main::Session*> session) {
return CountFeaturedHash(
session,
session->data().stickers().featuredEmojiSetsOrder());
}
uint64 CountSavedGifsHash(not_null<Main::Session*> session) {