summary refs log tree commit diff
path: root/src/Cache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Cache.cpp')
-rw-r--r--src/Cache.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp

index dd26157c..6db768d3 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp
@@ -3580,24 +3580,26 @@ Cache::getImagePacks(const std::string &room_id, std::optional<bool> stickers) auto addPack = [&infos, stickers](const mtx::events::msc2545::ImagePack &pack, const std::string &source_room, const std::string &state_key) { - if (!pack.pack || !stickers.has_value() || - (stickers.value() ? pack.pack->is_sticker() : pack.pack->is_emoji())) { - ImagePackInfo info; - info.source_room = source_room; - info.state_key = state_key; - info.pack.pack = pack.pack; + bool pack_matches = !stickers.has_value() || + (stickers.value() ? pack.pack->is_sticker() : pack.pack->is_emoji()); - for (const auto &img : pack.images) { - if (stickers.has_value() && img.second.overrides_usage() && - (stickers ? !img.second.is_sticker() : !img.second.is_emoji())) - continue; + ImagePackInfo info; + info.source_room = source_room; + info.state_key = state_key; + info.pack.pack = pack.pack; - info.pack.images.insert(img); - } + for (const auto &img : pack.images) { + if (stickers.has_value() && + (img.second.overrides_usage() + ? (!stickers.value() ? img.second.is_sticker() : img.second.is_emoji()) + : !pack_matches)) + continue; - if (!info.pack.images.empty()) - infos.push_back(std::move(info)); + info.pack.images.insert(img); } + + if (!info.pack.images.empty()) + infos.push_back(std::move(info)); }; // packs from account data