Add a message if you're trying to type without being logged in

Fix #484
This commit is contained in:
Rasmus Karlsson 2018-06-24 13:09:56 +00:00
parent 8b4f9d066e
commit be931df4f4
3 changed files with 22 additions and 0 deletions

View file

@ -137,6 +137,17 @@ void TwitchAccountManager::load()
});
}
bool TwitchAccountManager::isLoggedIn() const
{
if (!this->currentUser) {
return false;
}
// Once `TwitchAccount` class has a way to check, we should also return false if the credentials
// are incorrect
return !this->currentUser->isAnon();
}
bool TwitchAccountManager::removeUser(TwitchAccount *account)
{
const auto &accs = this->accounts.getVector();

View file

@ -47,6 +47,8 @@ public:
void reloadUsers();
void load();
bool isLoggedIn() const;
pajlada::Settings::Setting<std::string> currentUsername = {"/accounts/current", ""};
pajlada::Signals::NoArgSignal currentUserChanged;
pajlada::Signals::NoArgSignal userListUpdated;

View file

@ -142,6 +142,15 @@ void TwitchChannel::sendMessage(const QString &message)
{
auto app = getApp();
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(
messages::Message::createSystemMessage("You need to log in to send messages. You can "
"link your Twitch account in the settings."));
return;
}
debug::Log("[TwitchChannel:{}] Send message: {}", this->name, message);
// Do last message processing