From aff59495df5121f208da7b0e90a275d7dd5edd06 Mon Sep 17 00:00:00 2001 From: Leon Richardt Date: Sun, 4 Oct 2020 17:36:38 +0200 Subject: [PATCH] Improve "Login expired!" message (#2029) * feat: improve "Login expired!" message Since this message occurs when the OAuth token becomes invalid, users have to re-add their account in order to continue using the application. The previous message did not make this clear enough, often leading to confusion and questions by users. This commit changes the system message to more clear about what the user has to do, and adds a link that opens the "Accounts" page in the preferences. * Update changelog * Update ChannelView.cpp Co-authored-by: fourtf --- CHANGELOG.md | 1 + src/messages/Link.hpp | 1 + src/providers/twitch/IrcMessageHandler.cpp | 22 +++++++++++++++++++--- src/widgets/helper/ChannelView.cpp | 7 +++++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af00c80f..bd17c715 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Minor: Colorized nicknames now enabled by default - Minor: Show channels live now enabled by default - Minor: Bold usernames enabled by default +- Minor: Improve UX of the "Login expired!" message (#2029) - Bugfix: Fix bug preventing users from setting the highlight color of the second entry in the "User" highlights tab (#1898) - Bugfix: Fix bug where the "check user follow state" event could trigger a network request requesting the user to follow or unfollow a user. By itself its quite harmless as it just repeats to Twitch the same follow state we had, so no follows should have been lost by this but it meant there was a rogue network request that was fired that could cause a crash (#1906) - Bugfix: /usercard command will now respect the "Automatically close user popup" setting (#1918) diff --git a/src/messages/Link.hpp b/src/messages/Link.hpp index 4545ec8c..71634593 100644 --- a/src/messages/Link.hpp +++ b/src/messages/Link.hpp @@ -19,6 +19,7 @@ public: UserAction, AutoModAllow, AutoModDeny, + OpenAccountsPage, }; Link(); diff --git a/src/providers/twitch/IrcMessageHandler.cpp b/src/providers/twitch/IrcMessageHandler.cpp index a0a5cd6f..78398f3b 100644 --- a/src/providers/twitch/IrcMessageHandler.cpp +++ b/src/providers/twitch/IrcMessageHandler.cpp @@ -655,9 +655,25 @@ std::vector IrcMessageHandler::parseNoticeMessage( { if (message->content().startsWith("Login auth", Qt::CaseInsensitive)) { - return {MessageBuilder(systemMessage, - "Login expired! Try logging in again.") - .release()}; + const auto linkColor = MessageColor(MessageColor::Link); + const auto accountsLink = Link(Link::OpenAccountsPage, QString()); + const auto curUser = getApp()->accounts->twitch.getCurrent(); + const auto expirationText = QString("Login expired for user \"%1\"!") + .arg(curUser->getUserName()); + const auto loginPromptText = QString(" Try adding your account again."); + + auto builder = MessageBuilder(); + builder.message().flags.set(MessageFlag::System); + + builder.emplace(); + builder.emplace(expirationText, MessageElementFlag::Text, + MessageColor::System); + builder + .emplace(loginPromptText, MessageElementFlag::Text, + linkColor) + ->setLink(accountsLink); + + return {builder.release()}; } else { diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 6d4f5048..76e18594 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -38,6 +38,7 @@ #include "util/Twitch.hpp" #include "widgets/Scrollbar.hpp" #include "widgets/TooltipWidget.hpp" +#include "widgets/dialogs/SettingsDialog.hpp" #include "widgets/dialogs/UserInfoPopup.hpp" #include "widgets/helper/EffectLabel.hpp" #include "widgets/splits/Split.hpp" @@ -1879,6 +1880,12 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link, case Link::AutoModDeny: { getApp()->accounts->twitch.getCurrent()->autoModDeny(link.value); } + break; + + case Link::OpenAccountsPage: { + SettingsDialog::showDialog(SettingsDialogPreference::Accounts); + } + break; default:; }