feat: add option to suppress live notifications on startup (#5388)

This commit is contained in:
nerix
2024-07-20 14:19:27 +02:00
committed by GitHub
parent 4a7a5b09ce
commit 0495fbca43
11 changed files with 398 additions and 225 deletions
+6 -4
View File
@@ -56,7 +56,7 @@ void TwitchLiveController::add(const std::shared_ptr<TwitchChannel> &newChannel)
{
std::unique_lock lock(this->channelsMutex);
this->channels[channelID] = newChannel;
this->channels[channelID] = {.ptr = newChannel, .wasChecked = false};
}
{
@@ -120,9 +120,11 @@ void TwitchLiveController::request(std::optional<QStringList> optChannelIDs)
auto it = this->channels.find(result.first);
if (it != channels.end())
{
if (auto channel = it->second.lock(); channel)
if (auto channel = it->second.ptr.lock(); channel)
{
channel->updateStreamStatus(result.second);
channel->updateStreamStatus(
result.second, !it->second.wasChecked);
it->second.wasChecked = true;
}
else
{
@@ -159,7 +161,7 @@ void TwitchLiveController::request(std::optional<QStringList> optChannelIDs)
auto it = this->channels.find(helixChannel.userId);
if (it != this->channels.end())
{
if (auto channel = it->second.lock(); channel)
if (auto channel = it->second.ptr.lock(); channel)
{
channel->updateStreamTitle(helixChannel.title);
channel->updateDisplayName(helixChannel.name);
+6 -1
View File
@@ -49,6 +49,11 @@ public:
void add(const std::shared_ptr<TwitchChannel> &newChannel) override;
private:
struct ChannelEntry {
std::weak_ptr<TwitchChannel> ptr;
bool wasChecked = false;
};
/**
* Run batched Helix Channels & Stream requests for channels
*
@@ -64,7 +69,7 @@ private:
*
* These channels will have their stream status updated every REFRESH_INTERVAL seconds
**/
std::unordered_map<QString, std::weak_ptr<TwitchChannel>> channels;
std::unordered_map<QString, ChannelEntry> channels;
std::shared_mutex channelsMutex;
/**