diff --git a/CHANGELOG.md b/CHANGELOG.md index ecd3acb14..b9411ef4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Minor: Added autocompletion in /whispers for Twitch emotes, Global Bttv/Ffz emotes and emojis. (#2999, #3033) - Minor: Received Twitch messages now use the exact same timestamp (obtained from Twitch's server) for every Chatterino user instead of assuming message timestamp on client's side. (#3021) - Minor: Received IRC messages use `time` message tag for timestamp if it's available. (#3021) +- Minor: Added informative messages for recent-messages API's errors. (#3029) - Bugfix: Fixed "smiley" emotes being unable to be "Tabbed" with autocompletion, introduced in v2.3.3. (#3010) - Dev: Ubuntu packages are now available (#2936) diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index 884d20140..326ae9b53 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -761,13 +761,16 @@ void TwitchChannel::loadRecentMessages() .arg(baseURL) .arg(getSettings()->twitchMessageHistoryLimit); + auto weak = weakOf(this); + NetworkRequest(url) - .onSuccess([weak = weakOf(this)](auto result) -> Outcome { + .onSuccess([this, weak](NetworkResult result) -> Outcome { auto shared = weak.lock(); if (!shared) return Failure; - auto messages = parseRecentMessages(result.parseJson(), shared); + auto root = result.parseJson(); + auto messages = parseRecentMessages(root, shared); auto &handler = IrcMessageHandler::instance(); @@ -801,13 +804,38 @@ void TwitchChannel::loadRecentMessages() } } - postToThread( - [shared, messages = std::move(allBuiltMessages)]() mutable { - shared->addMessagesAtStart(messages); - }); + postToThread([this, shared, root, + messages = std::move(allBuiltMessages)]() mutable { + shared->addMessagesAtStart(messages); + + // Notify user about a possible gap in logs if it returned some messages + // but isn't currently joined to a channel + if (QString errorCode = root.value("error_code").toString(); + !errorCode.isEmpty()) + { + qCDebug(chatterinoTwitch) + << QString("rm error_code=%1, channel=%2") + .arg(errorCode, this->getName()); + if (errorCode == "channel_not_joined" && !messages.empty()) + { + shared->addMessage(makeSystemMessage( + "Message history service recovering, there may be " + "gaps in the message history.")); + } + } + }); return Success; }) + .onError([weak](NetworkResult result) { + auto shared = weak.lock(); + if (!shared) + return; + + shared->addMessage(makeSystemMessage( + QString("Message history service unavailable (Error %1)") + .arg(result.status()))); + }) .execute(); }