1 #pragma once 2 3 #include "common/Channel.hpp" 4 #include "common/ChatterSet.hpp" 5 #include "common/UniqueAccess.hpp" 6 #include "lrucache/lrucache.hpp" 7 #include "util/QStringHash.hpp" 8 9 #include <QRgb> 10 11 namespace chatterino { 12 13 class ChannelChatters 14 { 15 public: 16 ChannelChatters(Channel &channel); 17 virtual ~ChannelChatters() = default; // add vtable 18 19 SharedAccessGuard<const ChatterSet> accessChatters() const; 20 21 void addRecentChatter(const QString &user); 22 void addJoinedUser(const QString &user); 23 void addPartedUser(const QString &user); 24 const QColor getUserColor(const QString &user); 25 void setUserColor(const QString &user, const QColor &color); 26 void updateOnlineChatters(const std::unordered_set<QString> &chatters); 27 28 private: 29 static constexpr int maxChatterColorCount = 5000; 30 31 Channel &channel_; 32 33 // maps 2 char prefix to set of names 34 UniqueAccess<ChatterSet> chatters_; 35 UniqueAccess<cache::lru_cache<QString, QRgb>> chatterColors_; 36 37 // combines multiple joins/parts into one message 38 UniqueAccess<QStringList> joinedUsers_; 39 bool joinedUsersMergeQueued_ = false; 40 UniqueAccess<QStringList> partedUsers_; 41 bool partedUsersMergeQueued_ = false; 42 43 QObject lifetimeGuard_; 44 }; 45 46 } // namespace chatterino 47