Fix live status tooltip not updating properly

The issue was the TwitchChannel refreshLiveStatus function not calling
the updateLiveInfo signal properly

Fix #461
This commit is contained in:
Rasmus Karlsson 2018-06-11 11:51:46 +02:00
parent 511f60a181
commit 698814a21f
2 changed files with 22 additions and 11 deletions

View file

@ -31,19 +31,11 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection
{ {
debug::Log("[TwitchChannel:{}] Opened", this->name); debug::Log("[TwitchChannel:{}] Opened", this->name);
this->startRefreshLiveStatusTimer(60 * 1000);
auto app = getApp(); auto app = getApp();
this->reloadChannelEmotes(); this->reloadChannelEmotes();
this->liveStatusTimer = new QTimer;
QObject::connect(this->liveStatusTimer, &QTimer::timeout, [this]() {
this->refreshLiveStatus(); //
});
this->liveStatusTimer->start(60000);
this->roomIDchanged.connect([this]() {
this->refreshLiveStatus(); //
});
this->managedConnect(app->accounts->twitch.currentUserChanged, this->managedConnect(app->accounts->twitch.currentUserChanged,
[this]() { this->setMod(false); }); [this]() { this->setMod(false); });
@ -318,6 +310,7 @@ void TwitchChannel::setLive(bool newLiveStatus)
void TwitchChannel::refreshLiveStatus() void TwitchChannel::refreshLiveStatus()
{ {
if (this->roomID.isEmpty()) { if (this->roomID.isEmpty()) {
debug::Log("[TwitchChannel:{}] Refreshing live status (Missing ID)", this->name);
this->setLive(false); this->setLive(false);
return; return;
} }
@ -373,6 +366,7 @@ void TwitchChannel::refreshLiveStatus()
{ {
std::lock_guard<std::mutex> lock(channel->streamStatusMutex); std::lock_guard<std::mutex> lock(channel->streamStatusMutex);
channel->streamStatus.live = true;
channel->streamStatus.viewerCount = stream["viewers"].GetUint(); channel->streamStatus.viewerCount = stream["viewers"].GetUint();
channel->streamStatus.game = stream["game"].GetString(); channel->streamStatus.game = stream["game"].GetString();
channel->streamStatus.title = streamChannel["status"].GetString(); channel->streamStatus.title = streamChannel["status"].GetString();
@ -400,10 +394,26 @@ void TwitchChannel::refreshLiveStatus()
} }
} }
channel->setLive(true); // Signal all listeners that the stream status has been updated
channel->updateLiveInfo.invoke();
}); });
} }
void TwitchChannel::startRefreshLiveStatusTimer(int intervalMS)
{
this->liveStatusTimer = new QTimer;
QObject::connect(this->liveStatusTimer, &QTimer::timeout, [this]() {
this->refreshLiveStatus(); //
});
// When the Room ID of a twitch channel has been set, refresh the live status an extra time
this->roomIDchanged.connect([this]() {
this->refreshLiveStatus(); //
});
this->liveStatusTimer->start(intervalMS);
}
void TwitchChannel::fetchRecentMessages() void TwitchChannel::fetchRecentMessages()
{ {
static QString genericURL = static QString genericURL =

View file

@ -100,6 +100,7 @@ private:
void setLive(bool newLiveStatus); void setLive(bool newLiveStatus);
void refreshLiveStatus(); void refreshLiveStatus();
void startRefreshLiveStatusTimer(int intervalMS);
mutable std::mutex streamStatusMutex; mutable std::mutex streamStatusMutex;
StreamStatus streamStatus; StreamStatus streamStatus;