#include "channel.hpp" #include "debug/log.hpp" #include "logging/loggingmanager.hpp" #include "messages/message.hpp" #include "singletons/emotemanager.hpp" #include "singletons/ircmanager.hpp" #include "singletons/windowmanager.hpp" #include #include #include #include #include #include #include using namespace chatterino::messages; namespace chatterino { Channel::Channel(const QString &_name) : name(_name) // , loggingChannel(logging::get(name)) { } bool Channel::isEmpty() const { return false; } messages::LimitedQueueSnapshot Channel::getMessageSnapshot() { return this->messages.getSnapshot(); } void Channel::addMessage(std::shared_ptr message) { std::shared_ptr deleted; const QString &username = message->loginName; if (!username.isEmpty()) { // TODO: Add recent chatters display name. This should maybe be a setting this->addRecentChatter(message); } // if (_loggingChannel.get() != nullptr) { // _loggingChannel->append(message); // } if (this->messages.pushBack(message, deleted)) { messageRemovedFromStart(deleted); } this->messageAppended(message); } void Channel::addMessagesAtStart(std::vector &_messages) { std::vector addedMessages = this->messages.pushFront(_messages); if (addedMessages.size() != 0) { this->messagesAddedAtStart(addedMessages); } } void Channel::replaceMessage(messages::SharedMessage message, messages::SharedMessage replacement) { int index = this->messages.replaceItem(message, replacement); if (index >= 0) { this->messageReplaced((size_t)index, replacement); } } void Channel::addRecentChatter(const std::shared_ptr &message) { assert(!message->loginName.isEmpty()); std::lock_guard lock(this->recentChattersMutex); this->recentChatters[message->loginName] = {message->displayName, message->localizedName}; } std::vector Channel::getUsernamesForCompletions() { std::vector names; this->recentChattersMutex.lock(); for (const auto &p : this->recentChatters) { names.push_back(p.second); } // usernames.insert(this->recentChatters.begin(), this->recentChatters.end()); this->recentChattersMutex.unlock(); return names; } bool Channel::canSendMessage() const { return false; } void Channel::sendMessage(const QString &message) { } } // namespace chatterino