Refactored system message received upon trying to send a message while anonymous (#2862)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Paweł
2021-06-05 16:27:14 +02:00
committed by GitHub
parent 6611c24e13
commit 0b4c521c9b
2 changed files with 28 additions and 5 deletions
+27 -5
View File
@@ -328,11 +328,33 @@ void TwitchChannel::sendMessage(const QString &message)
if (!app->accounts->twitch.isLoggedIn())
{
// XXX: It would be nice if we could add a link here somehow that opened
// the "account manager" dialog
this->addMessage(
makeSystemMessage("You need to log in to send messages. You can "
"link your Twitch account in the settings."));
if (message.isEmpty())
{
return;
}
const auto linkColor = MessageColor(MessageColor::Link);
const auto accountsLink = Link(Link::OpenAccountsPage, QString());
const auto currentUser = getApp()->accounts->twitch.getCurrent();
const auto expirationText =
QString("You need to log in to send messages. You can link your "
"Twitch account");
const auto loginPromptText = QString("in the settings.");
auto builder = MessageBuilder();
builder.message().flags.set(MessageFlag::System);
builder.message().flags.set(MessageFlag::DoNotTriggerNotification);
builder.emplace<TimestampElement>();
builder.emplace<TextElement>(expirationText, MessageElementFlag::Text,
MessageColor::System);
builder
.emplace<TextElement>(loginPromptText, MessageElementFlag::Text,
linkColor)
->setLink(accountsLink);
this->addMessage(builder.release());
return;
}