Added system message if no bttv emotes found instead of "unknown error" (#2542)

Co-authored-by: Paweł <zneix@zneix.eu>
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Auro
2021-03-21 09:27:28 -04:00
committed by GitHub
parent a893cdaebe
commit 6ef515a0e2
3 changed files with 44 additions and 10 deletions
+22 -5
View File
@@ -15,6 +15,9 @@
namespace chatterino {
namespace {
const QString CHANNEL_HAS_NO_EMOTES(
"This channel has no BetterTTV channel emotes.");
QString emoteLinkFormat("https://betterttv.com/emotes/%1");
Url getEmoteLink(QString urlTemplate, const EmoteId &id,
@@ -164,23 +167,37 @@ void BttvEmotes::loadChannel(std::weak_ptr<Channel> channel,
manualRefresh](auto result) -> Outcome {
auto pair =
parseChannelEmotes(result.parseJson(), channelDisplayName);
bool hasEmotes = false;
if (pair.first)
{
hasEmotes = !pair.second.empty();
callback(std::move(pair.second));
}
if (auto shared = channel.lock(); manualRefresh)
shared->addMessage(
makeSystemMessage("BetterTTV channel emotes reloaded."));
{
if (hasEmotes)
{
shared->addMessage(makeSystemMessage(
"BetterTTV channel emotes reloaded."));
}
else
{
shared->addMessage(
makeSystemMessage(CHANNEL_HAS_NO_EMOTES));
}
}
return pair.first;
})
.onError([channelId, channel, manualRefresh](auto result) {
auto shared = channel.lock();
if (!shared)
return;
if (result.status() == 203)
if (result.status() == 404)
{
// User does not have any BTTV emotes
if (manualRefresh)
shared->addMessage(makeSystemMessage(
"This channel has no BetterTTV channel emotes."));
shared->addMessage(
makeSystemMessage(CHANNEL_HAS_NO_EMOTES));
}
else if (result.status() == NetworkResult::timedoutStatus)
{