Add better checks when the pack is omitted from im.ponies.room_emotes

This field is omittable, and I hit it this morning. Let's check if it's
filled before using it.
This commit is contained in:
Joshua Goins
2023-05-27 09:07:53 -04:00
committed by Tobias Fella
parent 09ced090f2
commit cc80e69644

View File

@@ -102,12 +102,13 @@ void ImagePacksModel::reloadImages()
const auto &stickerRoom = m_room->connection()->room(roomId);
for (const auto &packKey : packs.keys()) {
#ifdef QUOTIENT_07
const auto &pack = stickerRoom->currentState().get<ImagePackEvent>(packKey);
if (pack) {
if (const auto &pack = stickerRoom->currentState().get<ImagePackEvent>(packKey)) {
const auto packContent = pack->content();
if (!packContent.pack->usage || (packContent.pack->usage->contains("emoticon") && showEmoticons())
|| (packContent.pack->usage->contains("sticker") && showStickers())) {
m_events += packContent;
if (packContent.pack.has_value()) {
if (!packContent.pack->usage || (packContent.pack->usage->contains("emoticon") && showEmoticons())
|| (packContent.pack->usage->contains("sticker") && showStickers())) {
m_events += packContent;
}
}
}
#endif
@@ -118,9 +119,11 @@ void ImagePacksModel::reloadImages()
auto events = m_room->currentState().eventsOfType("im.ponies.room_emotes");
for (const auto &event : events) {
auto packContent = eventCast<const ImagePackEvent>(event)->content();
if (!packContent.pack->usage || (packContent.pack->usage->contains("emoticon") && showEmoticons())
|| (packContent.pack->usage->contains("sticker") && showStickers())) {
m_events += packContent;
if (packContent.pack.has_value()) {
if (!packContent.pack->usage || (packContent.pack->usage->contains("emoticon") && showEmoticons())
|| (packContent.pack->usage->contains("sticker") && showStickers())) {
m_events += packContent;
}
}
}
#endif