No longer add username to the completion model in privateMessageReceived
The username is added to the completion model with the "addRecentChatter" method instead Moved "NameOptions" stuff from base class Channel to TwitchChannel where it belongs Remove unused Channel::getUsernamesForCompletions method
This commit is contained in:
@@ -163,6 +163,17 @@ bool TwitchChannel::hasModRights()
|
||||
return this->isMod() || this->isBroadcaster();
|
||||
}
|
||||
|
||||
void TwitchChannel::addRecentChatter(const std::shared_ptr<messages::Message> &message)
|
||||
{
|
||||
assert(!message->loginName.isEmpty());
|
||||
|
||||
std::lock_guard<std::mutex> lock(this->recentChattersMutex);
|
||||
|
||||
this->recentChatters[message->loginName] = {message->displayName, message->localizedName};
|
||||
|
||||
this->completionModel.addUser(message->displayName);
|
||||
}
|
||||
|
||||
void TwitchChannel::setLive(bool newLiveStatus)
|
||||
{
|
||||
if (this->isLive == newLiveStatus) {
|
||||
|
||||
@@ -33,6 +33,8 @@ public:
|
||||
bool isBroadcaster();
|
||||
bool hasModRights();
|
||||
|
||||
void addRecentChatter(const std::shared_ptr<messages::Message> &message) final;
|
||||
|
||||
const std::shared_ptr<chatterino::util::EmoteMap> bttvChannelEmotes;
|
||||
const std::shared_ptr<chatterino::util::EmoteMap> ffzChannelEmotes;
|
||||
|
||||
@@ -54,6 +56,11 @@ public:
|
||||
QString streamGame;
|
||||
QString streamUptime;
|
||||
|
||||
struct NameOptions {
|
||||
QString displayName;
|
||||
QString localizedName;
|
||||
};
|
||||
|
||||
private:
|
||||
explicit TwitchChannel(const QString &channelName, Communi::IrcConnection *readConnection);
|
||||
|
||||
@@ -71,6 +78,10 @@ private:
|
||||
Communi::IrcConnection *readConnecetion;
|
||||
|
||||
friend class TwitchServer;
|
||||
|
||||
// Key = login name
|
||||
std::map<QString, NameOptions> recentChatters;
|
||||
std::mutex recentChattersMutex;
|
||||
};
|
||||
|
||||
} // namespace twitch
|
||||
|
||||
@@ -90,9 +90,6 @@ void TwitchServer::privateMessageReceived(IrcPrivateMessage *message)
|
||||
|
||||
TwitchMessageBuilder builder(chan.get(), message, args);
|
||||
|
||||
// XXX: Thread-safety
|
||||
chan->completionModel.addUser(message->nick());
|
||||
|
||||
if (!builder.isIgnored()) {
|
||||
messages::MessagePtr _message = builder.build();
|
||||
if (_message->flags & messages::Message::Highlighted) {
|
||||
|
||||
Reference in New Issue
Block a user