From 8ec328f3527279d576c2c92c24b4a4126f007d33 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 27 Nov 2018 21:29:59 +0300 Subject: [PATCH] Fixed moderation buttons in UserInfoPopup from SearchPopup. --- src/widgets/dialogs/UserInfoPopup.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index 09244b9b3..10ad52fc8 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -115,6 +115,9 @@ UserInfoPopup::UserInfoPopup() TwitchChannel *twitchChannel = dynamic_cast(this->channel_.get()); + bool visibilityMod = false; + bool visibilityUnmod = false; + if (twitchChannel) { qDebug() << this->userName_; @@ -124,11 +127,12 @@ UserInfoPopup::UserInfoPopup() getApp()->accounts->twitch.getCurrent()->getUserName(), this->userName_, Qt::CaseInsensitive) == 0; - mod->setVisible(twitchChannel->isBroadcaster() && !isMyself); - unmod->setVisible( - (twitchChannel->isBroadcaster() && !isMyself) || - (twitchChannel->isMod() && isMyself)); + visibilityMod = twitchChannel->isBroadcaster() && !isMyself; + visibilityUnmod = visibilityMod || + (twitchChannel->isMod() && isMyself); } + mod->setVisible(visibilityMod); + unmod->setVisible(visibilityUnmod); }); } @@ -143,11 +147,10 @@ UserInfoPopup::UserInfoPopup() TwitchChannel *twitchChannel = dynamic_cast(this->channel_.get()); - if (twitchChannel) - { - lineMod->setVisible(twitchChannel->hasModRights()); - timeout->setVisible(twitchChannel->hasModRights()); - } + bool hasModRights = twitchChannel ? twitchChannel->hasModRights() + : false; + lineMod->setVisible(hasModRights); + timeout->setVisible(hasModRights); }); timeout->buttonClicked.connect([this](auto item) {