From 8ea3b6c8eebf2475d8472ead52220cfb2251ab2a Mon Sep 17 00:00:00 2001 From: apa420 Date: Sun, 26 Aug 2018 13:19:09 +0200 Subject: [PATCH] Added fakechannels --- .../notifications/NotificationController.cpp | 34 ++++++++----------- .../notifications/NotificationController.hpp | 11 +++--- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/controllers/notifications/NotificationController.cpp b/src/controllers/notifications/NotificationController.cpp index 54a964cfb..b35dc4cdc 100644 --- a/src/controllers/notifications/NotificationController.cpp +++ b/src/controllers/notifications/NotificationController.cpp @@ -36,18 +36,17 @@ void NotificationController::initialize(Settings &settings, Paths &paths) this->channelMap[Platform::Mixer].delayedItemsChanged.connect([this] { // this->mixerSetting_.setValue( this->channelMap[Platform::Mixer].getVector()); - }); - */ + });*/ - /* - connect(liveStatusTimer_, SIGNAL(timeout()), this, SLOT()); - liveStatusTimer_.start(60 * 1000); - */ liveStatusTimer_ = new QTimer(); - QObject::connect(liveStatusTimer_, this, SIGNAL(timeout()), - SLOT(fetchFakeChannels())); - connect(liveStatusTimer_, SIGNAL(timeout()), SLOT(fetchFakeChannels())); - liveStatusTimer_->start(1000); + + this->fetchFakeChannels(); + + QObject::connect(this->liveStatusTimer_, &QTimer::timeout, [=] { + this->fetchFakeChannels(); + qDebug() << " MY CODE IS SHIT OMEGALUL "; + }); + this->liveStatusTimer_->start(60 * 1000); } void NotificationController::updateChannelNotification( @@ -118,19 +117,15 @@ 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( channelMap[Platform::Twitch].getVector()[i]); - - /* - auto chan = getApp()->twitch.server->getChannelOrEmpty(chanName); - if (auto *twitchChannel = dynamic_cast(chan.get())) { - if (channelMap[Platform::Twitch].getVector()[i].toLower() == - channelName.toLower()) { channelMap[Platform::Twitch].removeItem(i); - i--; + if (chan->isEmpty()) { + getFakeTwitchChannelLiveStatus( + channelMap[Platform::Twitch].getVector()[i]); } - }*/ } } @@ -172,7 +167,8 @@ void NotificationController::getFakeTwitchChannelLiveStatus( // Stream is live auto i = std::find(fakeTwitchChannels.begin(), fakeTwitchChannels.end(), channelName); - if (i != fakeTwitchChannels.end()) { + + if (!(i != fakeTwitchChannels.end())) { fakeTwitchChannels.push_back(channelName); if (Toasts::isEnabled()) { getApp()->toasts->sendChannelNotification(channelName, diff --git a/src/controllers/notifications/NotificationController.hpp b/src/controllers/notifications/NotificationController.hpp index a7cdbaf41..77e8d46b1 100644 --- a/src/controllers/notifications/NotificationController.hpp +++ b/src/controllers/notifications/NotificationController.hpp @@ -17,7 +17,7 @@ enum class Platform : uint8_t { // Mixer, // 1 }; -class NotificationController final : public Singleton +class NotificationController final : public Singleton, private QObject { public: virtual void initialize(Settings &settings, Paths &paths) override; @@ -37,19 +37,20 @@ public: private: bool initialized_ = false; - QTimer *liveStatusTimer_; + + void fetchFakeChannels(); void removeFakeChannel(const QString channelName); - std::vector fakeTwitchChannels; void getFakeTwitchChannelLiveStatus(const QString &channelName); + std::vector fakeTwitchChannels; + QTimer *liveStatusTimer_; + ChatterinoSetting> twitchSetting_ = { "/notifications/twitch"}; /* ChatterinoSetting> mixerSetting_ = { "/notifications/mixer"}; */ -private slots: - void fetchFakeChannels(); }; } // namespace chatterino