optimize chatter list (#2814)
* optimize chatter list * changelog * Fix tests Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -119,13 +119,14 @@ namespace {
|
||||
|
||||
return messages;
|
||||
}
|
||||
std::pair<Outcome, UsernameSet> parseChatters(const QJsonObject &jsonRoot)
|
||||
std::pair<Outcome, std::unordered_set<QString>> parseChatters(
|
||||
const QJsonObject &jsonRoot)
|
||||
{
|
||||
static QStringList categories = {"broadcaster", "vips", "moderators",
|
||||
"staff", "admins", "global_mods",
|
||||
"viewers"};
|
||||
|
||||
auto usernames = UsernameSet();
|
||||
auto usernames = std::unordered_set<QString>();
|
||||
|
||||
// parse json
|
||||
QJsonObject jsonCategories = jsonRoot.value("chatters").toObject();
|
||||
@@ -823,7 +824,7 @@ void TwitchChannel::refreshChatters()
|
||||
auto pair = parseChatters(std::move(data));
|
||||
if (pair.first)
|
||||
{
|
||||
this->setChatters(std::move(pair.second));
|
||||
this->updateOnlineChatters(pair.second);
|
||||
}
|
||||
|
||||
return pair.first;
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#include "common/Atomic.hpp"
|
||||
#include "common/Channel.hpp"
|
||||
#include "common/ChannelChatters.hpp"
|
||||
#include "common/ChatterSet.hpp"
|
||||
#include "common/Outcome.hpp"
|
||||
#include "common/UniqueAccess.hpp"
|
||||
#include "common/UsernameSet.hpp"
|
||||
#include "providers/twitch/ChannelPointReward.hpp"
|
||||
#include "providers/twitch/TwitchEmotes.hpp"
|
||||
#include "providers/twitch/api/Helix.hpp"
|
||||
|
||||
@@ -519,11 +519,11 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_)
|
||||
|
||||
if (this->twitchChannel != nullptr && getSettings()->findAllUsernames)
|
||||
{
|
||||
auto chatters = this->twitchChannel->accessChatters();
|
||||
auto match = allUsernamesMentionRegex.match(string);
|
||||
QString username = match.captured(1);
|
||||
|
||||
if (match.hasMatch() && chatters->contains(username))
|
||||
if (match.hasMatch() &&
|
||||
this->twitchChannel->accessChatters()->contains(username))
|
||||
{
|
||||
auto originalTextColor = textColor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user