Add cached emotes fallback for failed provider fetches (#6125)
This commit is contained in:
@@ -327,6 +327,17 @@ void TwitchChannel::refreshBTTVChannelEmotes(bool manualRefresh)
|
||||
return;
|
||||
}
|
||||
|
||||
bool cacheHit = readProviderEmotesCache(
|
||||
this->roomId(), "betterttv",
|
||||
[this, weak = weakOf<Channel>(this)](auto jsonDoc) {
|
||||
if (auto shared = weak.lock())
|
||||
{
|
||||
auto emoteMap = bttv::detail::parseChannelEmotes(
|
||||
jsonDoc.object(), this->getLocalizedName());
|
||||
this->setBttvEmotes(std::make_shared<const EmoteMap>(emoteMap));
|
||||
}
|
||||
});
|
||||
|
||||
BttvEmotes::loadChannel(
|
||||
weakOf<Channel>(this), this->roomId(), this->getLocalizedName(),
|
||||
[this, weak = weakOf<Channel>(this)](auto &&emoteMap) {
|
||||
@@ -335,7 +346,7 @@ void TwitchChannel::refreshBTTVChannelEmotes(bool manualRefresh)
|
||||
this->setBttvEmotes(std::make_shared<const EmoteMap>(emoteMap));
|
||||
}
|
||||
},
|
||||
manualRefresh);
|
||||
manualRefresh, cacheHit);
|
||||
}
|
||||
|
||||
void TwitchChannel::refreshFFZChannelEmotes(bool manualRefresh)
|
||||
@@ -346,6 +357,12 @@ void TwitchChannel::refreshFFZChannelEmotes(bool manualRefresh)
|
||||
return;
|
||||
}
|
||||
|
||||
bool cacheHit = readProviderEmotesCache(
|
||||
this->roomId(), "frankerfacez", [this](const auto &jsonDoc) {
|
||||
auto emoteMap = ffz::detail::parseChannelEmotes(jsonDoc.object());
|
||||
this->setFfzEmotes(std::make_shared<const EmoteMap>(emoteMap));
|
||||
});
|
||||
|
||||
FfzEmotes::loadChannel(
|
||||
weakOf<Channel>(this), this->roomId(),
|
||||
[this, weak = weakOf<Channel>(this)](auto &&emoteMap) {
|
||||
@@ -376,7 +393,7 @@ void TwitchChannel::refreshFFZChannelEmotes(bool manualRefresh)
|
||||
std::forward<decltype(channelBadges)>(channelBadges);
|
||||
}
|
||||
},
|
||||
manualRefresh);
|
||||
manualRefresh, cacheHit);
|
||||
}
|
||||
|
||||
void TwitchChannel::refreshSevenTVChannelEmotes(bool manualRefresh)
|
||||
@@ -387,6 +404,15 @@ void TwitchChannel::refreshSevenTVChannelEmotes(bool manualRefresh)
|
||||
return;
|
||||
}
|
||||
|
||||
bool cacheHit = readProviderEmotesCache(
|
||||
this->roomId(), "seventv", [this](auto jsonDoc) {
|
||||
const auto json = jsonDoc.object();
|
||||
const auto emoteSet = json["emote_set"].toObject();
|
||||
const auto parsedEmotes = emoteSet["emotes"].toArray();
|
||||
auto emoteMap = seventv::detail::parseEmotes(parsedEmotes, false);
|
||||
this->setSeventvEmotes(std::make_shared<const EmoteMap>(emoteMap));
|
||||
});
|
||||
|
||||
SeventvEmotes::loadChannelEmotes(
|
||||
weakOf<Channel>(this), this->roomId(),
|
||||
[this, weak = weakOf<Channel>(this)](auto &&emoteMap,
|
||||
@@ -401,7 +427,7 @@ void TwitchChannel::refreshSevenTVChannelEmotes(bool manualRefresh)
|
||||
channelInfo.twitchConnectionIndex;
|
||||
}
|
||||
},
|
||||
manualRefresh);
|
||||
manualRefresh, cacheHit);
|
||||
}
|
||||
|
||||
void TwitchChannel::setBttvEmotes(std::shared_ptr<const EmoteMap> &&map)
|
||||
|
||||
Reference in New Issue
Block a user