2020-10-18 15:54:48 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common/Channel.hpp"
|
2021-05-24 12:13:59 +02:00
|
|
|
#include "common/ChatterSet.hpp"
|
2020-10-18 15:54:48 +02:00
|
|
|
#include "common/UniqueAccess.hpp"
|
2021-03-13 15:34:11 +01:00
|
|
|
#include "lrucache/lrucache.hpp"
|
2021-05-24 12:13:59 +02:00
|
|
|
#include "util/QStringHash.hpp"
|
2020-10-18 15:54:48 +02:00
|
|
|
|
2021-05-08 15:57:00 +02:00
|
|
|
#include <QRgb>
|
|
|
|
|
2020-10-18 15:54:48 +02:00
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
class ChannelChatters
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ChannelChatters(Channel &channel);
|
|
|
|
virtual ~ChannelChatters() = default; // add vtable
|
|
|
|
|
2021-05-24 12:13:59 +02:00
|
|
|
SharedAccessGuard<const ChatterSet> accessChatters() const;
|
2020-10-18 15:54:48 +02:00
|
|
|
|
|
|
|
void addRecentChatter(const QString &user);
|
|
|
|
void addJoinedUser(const QString &user);
|
|
|
|
void addPartedUser(const QString &user);
|
2020-12-19 14:42:20 +01:00
|
|
|
const QColor getUserColor(const QString &user);
|
|
|
|
void setUserColor(const QString &user, const QColor &color);
|
2021-05-24 12:13:59 +02:00
|
|
|
void updateOnlineChatters(const std::unordered_set<QString> &chatters);
|
2020-10-18 15:54:48 +02:00
|
|
|
|
2021-08-21 12:38:38 +02:00
|
|
|
// colorsSize returns the amount of colors stored in `chatterColors_`
|
|
|
|
// NOTE: This function is only meant to be used in tests and benchmarks
|
|
|
|
size_t colorsSize() const;
|
|
|
|
|
2021-03-13 15:34:11 +01:00
|
|
|
static constexpr int maxChatterColorCount = 5000;
|
|
|
|
|
2021-08-21 12:38:38 +02:00
|
|
|
private:
|
2020-10-18 15:54:48 +02:00
|
|
|
Channel &channel_;
|
|
|
|
|
|
|
|
// maps 2 char prefix to set of names
|
2021-05-24 12:13:59 +02:00
|
|
|
UniqueAccess<ChatterSet> chatters_;
|
2021-03-13 15:34:11 +01:00
|
|
|
UniqueAccess<cache::lru_cache<QString, QRgb>> chatterColors_;
|
2020-10-18 15:54:48 +02:00
|
|
|
|
|
|
|
// combines multiple joins/parts into one message
|
|
|
|
UniqueAccess<QStringList> joinedUsers_;
|
|
|
|
bool joinedUsersMergeQueued_ = false;
|
|
|
|
UniqueAccess<QStringList> partedUsers_;
|
|
|
|
bool partedUsersMergeQueued_ = false;
|
|
|
|
|
|
|
|
QObject lifetimeGuard_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace chatterino
|