From 01ca055763da79af6aeed40f2c8111f4c8e8feef Mon Sep 17 00:00:00 2001 From: apa420 Date: Wed, 29 Aug 2018 22:22:32 +0200 Subject: [PATCH] fixed issue where when a channel was going offline it would do a toast if the channel was notified --- .../notifications/NotificationController.cpp | 7 +--- src/providers/twitch/TwitchChannel.cpp | 37 +++++++++++-------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/controllers/notifications/NotificationController.cpp b/src/controllers/notifications/NotificationController.cpp index 1e8e1b802..bab44b76b 100644 --- a/src/controllers/notifications/NotificationController.cpp +++ b/src/controllers/notifications/NotificationController.cpp @@ -45,10 +45,8 @@ void NotificationController::initialize(Settings &settings, Paths &paths) this->fetchFakeChannels(); - QObject::connect(this->liveStatusTimer_, &QTimer::timeout, [=] { - this->fetchFakeChannels(); - qDebug() << " MY CODE IS SHIT OMEGALUL "; - }); + QObject::connect(this->liveStatusTimer_, &QTimer::timeout, + [=] { this->fetchFakeChannels(); }); this->liveStatusTimer_->start(60 * 1000); } @@ -120,7 +118,6 @@ NotificationModel *NotificationController::createModel(QObject *parent, void NotificationController::fetchFakeChannels() { - qDebug() << " USING DEBUGGER "; for (std::vector::size_type i = 0; i != channelMap[Platform::Twitch].getVector().size(); i++) { auto chan = getApp()->twitch.server->getChannelOrEmpty( diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index b091ea42f..fecaffe0c 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -395,23 +395,30 @@ void TwitchChannel::setLive(bool newLiveStatus) auto guard = this->streamStatus_.access(); if (guard->live != newLiveStatus) { gotNewLiveStatus = true; - if (getApp()->notifications->isChannelNotified(this->getName(), - Platform::Twitch)) { - if (Toasts::isEnabled()) { - getApp()->toasts->sendChannelNotification(this->getName(), - Platform::Twitch); - } - if (getSettings()->notificationPlaySound) { - getApp()->notifications->playSound(); - } - if (getSettings()->notificationFlashTaskbar) { - QApplication::alert( - getApp()->windows->getMainWindow().window(), 2500); + if (newLiveStatus) { + if (getApp()->notifications->isChannelNotified( + this->getName(), Platform::Twitch)) { + if (Toasts::isEnabled()) { + getApp()->toasts->sendChannelNotification( + this->getName(), Platform::Twitch); + } + if (getSettings()->notificationPlaySound) { + getApp()->notifications->playSound(); + } + if (getSettings()->notificationFlashTaskbar) { + QApplication::alert( + getApp()->windows->getMainWindow().window(), 2500); + } } + auto live = makeSystemMessage(this->getName() + " is live"); + this->addMessage(live); + this->tabHighlightRequested.invoke( + HighlightState::Notification); + } else { + auto offline = + makeSystemMessage(this->getName() + " is offline"); + this->addMessage(offline); } - auto live = makeSystemMessage(this->getName() + " is live"); - this->addMessage(live); - this->tabHighlightRequested.invoke(HighlightState::Notification); guard->live = newLiveStatus; } }