mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Compare commits
8 commits
a62b986fbd
...
adea07250f
Author | SHA1 | Date | |
---|---|---|---|
adea07250f | |||
e537fca186 | |||
8eec1da317 | |||
90211cca55 | |||
bbcd8c5eb2 | |||
417cdbc009 | |||
7b5a21d088 | |||
ad21098bf2 |
|
@ -114,6 +114,8 @@
|
||||||
- Dev: Refactored static `MessageBuilder` helpers to standalone functions. (#5652)
|
- Dev: Refactored static `MessageBuilder` helpers to standalone functions. (#5652)
|
||||||
- Dev: Decoupled reply parsing from `MessageBuilder`. (#5660, #5668)
|
- Dev: Decoupled reply parsing from `MessageBuilder`. (#5660, #5668)
|
||||||
- Dev: Refactored IRC message building. (#5663)
|
- Dev: Refactored IRC message building. (#5663)
|
||||||
|
- Dev: Fixed some compiler warnings. (#5672)
|
||||||
|
- Dev: Unified parsing of historic and live IRC messages. (#5678)
|
||||||
|
|
||||||
## 2.5.1
|
## 2.5.1
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
cmake_minimum_required(VERSION 3.15)
|
cmake_minimum_required(VERSION 3.15)
|
||||||
cmake_policy(SET CMP0087 NEW) # evaluates generator expressions in `install(CODE/SCRIPT)`
|
cmake_policy(SET CMP0087 NEW) # evaluates generator expressions in `install(CODE/SCRIPT)`
|
||||||
cmake_policy(SET CMP0091 NEW) # select MSVC runtime library through `CMAKE_MSVC_RUNTIME_LIBRARY`
|
cmake_policy(SET CMP0091 NEW) # select MSVC runtime library through `CMAKE_MSVC_RUNTIME_LIBRARY`
|
||||||
|
if (POLICY CMP0167)
|
||||||
|
cmake_policy(SET CMP0167 NEW) # find Boost's own CMake config file
|
||||||
|
endif ()
|
||||||
include(FeatureSummary)
|
include(FeatureSummary)
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH
|
list(APPEND CMAKE_MODULE_PATH
|
||||||
|
|
|
@ -350,7 +350,7 @@ public:
|
||||||
// contains a comma
|
// contains a comma
|
||||||
MOCK_METHOD(
|
MOCK_METHOD(
|
||||||
void, getChatters,
|
void, getChatters,
|
||||||
(QString broadcasterID, QString moderatorID, int maxChattersToFetch,
|
(QString broadcasterID, QString moderatorID, size_t maxChattersToFetch,
|
||||||
ResultCallback<HelixChatters> successCallback,
|
ResultCallback<HelixChatters> successCallback,
|
||||||
(FailureCallback<HelixGetChattersError, QString> failureCallback)),
|
(FailureCallback<HelixGetChattersError, QString> failureCallback)),
|
||||||
(override)); // getChatters
|
(override)); // getChatters
|
||||||
|
|
|
@ -2,6 +2,7 @@ set(LIBRARY_PROJECT "${PROJECT_NAME}-lib")
|
||||||
set(VERSION_PROJECT "${LIBRARY_PROJECT}-version")
|
set(VERSION_PROJECT "${LIBRARY_PROJECT}-version")
|
||||||
set(EXECUTABLE_PROJECT "${PROJECT_NAME}")
|
set(EXECUTABLE_PROJECT "${PROJECT_NAME}")
|
||||||
add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x050F00)
|
add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x050F00)
|
||||||
|
add_compile_definitions(QT_WARN_DEPRECATED_UP_TO=0x050F00)
|
||||||
|
|
||||||
# registers the native messageing host
|
# registers the native messageing host
|
||||||
option(CHATTERINO_DEBUG_NATIVE_MESSAGES "Debug native messages" OFF)
|
option(CHATTERINO_DEBUG_NATIVE_MESSAGES "Debug native messages" OFF)
|
||||||
|
@ -39,6 +40,7 @@ set(SOURCE_FILES
|
||||||
common/WindowDescriptors.cpp
|
common/WindowDescriptors.cpp
|
||||||
common/WindowDescriptors.hpp
|
common/WindowDescriptors.hpp
|
||||||
|
|
||||||
|
common/enums/MessageContext.hpp
|
||||||
common/enums/MessageOverflow.hpp
|
common/enums/MessageOverflow.hpp
|
||||||
|
|
||||||
common/network/NetworkCommon.cpp
|
common/network/NetworkCommon.cpp
|
||||||
|
@ -281,6 +283,9 @@ set(SOURCE_FILES
|
||||||
messages/MessageElement.cpp
|
messages/MessageElement.cpp
|
||||||
messages/MessageElement.hpp
|
messages/MessageElement.hpp
|
||||||
messages/MessageFlag.hpp
|
messages/MessageFlag.hpp
|
||||||
|
messages/MessageSimilarity.cpp
|
||||||
|
messages/MessageSimilarity.hpp
|
||||||
|
messages/MessageSink.hpp
|
||||||
messages/MessageThread.cpp
|
messages/MessageThread.cpp
|
||||||
messages/MessageThread.hpp
|
messages/MessageThread.hpp
|
||||||
|
|
||||||
|
@ -526,6 +531,8 @@ set(SOURCE_FILES
|
||||||
util/Twitch.hpp
|
util/Twitch.hpp
|
||||||
util/TypeName.hpp
|
util/TypeName.hpp
|
||||||
util/Variant.hpp
|
util/Variant.hpp
|
||||||
|
util/VectorMessageSink.cpp
|
||||||
|
util/VectorMessageSink.hpp
|
||||||
util/WidgetHelpers.cpp
|
util/WidgetHelpers.cpp
|
||||||
util/WidgetHelpers.hpp
|
util/WidgetHelpers.hpp
|
||||||
util/WindowsHelper.cpp
|
util/WindowsHelper.cpp
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "messages/Message.hpp"
|
#include "messages/Message.hpp"
|
||||||
#include "messages/MessageBuilder.hpp"
|
#include "messages/MessageBuilder.hpp"
|
||||||
|
#include "messages/MessageSimilarity.hpp"
|
||||||
#include "providers/twitch/IrcMessageHandler.hpp"
|
#include "providers/twitch/IrcMessageHandler.hpp"
|
||||||
|
#include "providers/twitch/TwitchIrcServer.hpp"
|
||||||
#include "singletons/Emotes.hpp"
|
#include "singletons/Emotes.hpp"
|
||||||
#include "singletons/Logging.hpp"
|
#include "singletons/Logging.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
|
@ -121,10 +123,10 @@ void Channel::addSystemMessage(const QString &contents)
|
||||||
this->addMessage(msg, MessageContext::Original);
|
this->addMessage(msg, MessageContext::Original);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Channel::addOrReplaceTimeout(MessagePtr message)
|
void Channel::addOrReplaceTimeout(MessagePtr message, QTime now)
|
||||||
{
|
{
|
||||||
addOrReplaceChannelTimeout(
|
addOrReplaceChannelTimeout(
|
||||||
this->getMessageSnapshot(), std::move(message), QTime::currentTime(),
|
this->getMessageSnapshot(), std::move(message), now,
|
||||||
[this](auto /*idx*/, auto msg, auto replacement) {
|
[this](auto /*idx*/, auto msg, auto replacement) {
|
||||||
this->replaceMessage(msg, replacement);
|
this->replaceMessage(msg, replacement);
|
||||||
},
|
},
|
||||||
|
@ -287,10 +289,15 @@ void Channel::clearMessages()
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagePtr Channel::findMessage(QString messageID)
|
MessagePtr Channel::findMessage(QString messageID)
|
||||||
|
{
|
||||||
|
return this->findMessageByID(messageID);
|
||||||
|
}
|
||||||
|
|
||||||
|
MessagePtr Channel::findMessageByID(QStringView messageID)
|
||||||
{
|
{
|
||||||
MessagePtr res;
|
MessagePtr res;
|
||||||
|
|
||||||
if (auto msg = this->messages_.rfind([&messageID](const MessagePtr &msg) {
|
if (auto msg = this->messages_.rfind([messageID](const MessagePtr &msg) {
|
||||||
return msg->id == messageID;
|
return msg->id == messageID;
|
||||||
});
|
});
|
||||||
msg)
|
msg)
|
||||||
|
@ -301,6 +308,19 @@ MessagePtr Channel::findMessage(QString messageID)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Channel::applySimilarityFilters(const MessagePtr &message) const
|
||||||
|
{
|
||||||
|
setSimilarityFlags(message, this->messages_.getSnapshot());
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageSinkTraits Channel::sinkTraits() const
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
MessageSinkTrait::AddMentionsToGlobalChannel,
|
||||||
|
MessageSinkTrait::RequiresKnownChannelPointReward,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
bool Channel::canSendMessage() const
|
bool Channel::canSendMessage() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/enums/MessageContext.hpp"
|
||||||
#include "controllers/completion/TabCompletionModel.hpp"
|
#include "controllers/completion/TabCompletionModel.hpp"
|
||||||
#include "messages/LimitedQueue.hpp"
|
#include "messages/LimitedQueue.hpp"
|
||||||
#include "messages/MessageFlag.hpp"
|
#include "messages/MessageFlag.hpp"
|
||||||
|
#include "messages/MessageSink.hpp"
|
||||||
|
|
||||||
#include <magic_enum/magic_enum.hpp>
|
#include <magic_enum/magic_enum.hpp>
|
||||||
#include <pajlada/signals/signal.hpp>
|
#include <pajlada/signals/signal.hpp>
|
||||||
|
@ -26,15 +28,7 @@ enum class TimeoutStackStyle : int {
|
||||||
Default = DontStackBeyondUserMessage,
|
Default = DontStackBeyondUserMessage,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Context of the message being added to a channel
|
class Channel : public std::enable_shared_from_this<Channel>, public MessageSink
|
||||||
enum class MessageContext {
|
|
||||||
/// This message is the original
|
|
||||||
Original,
|
|
||||||
/// This message is a repost of a message that has already been added in a channel
|
|
||||||
Repost,
|
|
||||||
};
|
|
||||||
|
|
||||||
class Channel : public std::enable_shared_from_this<Channel>
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// This is for Lua. See scripts/make_luals_meta.py
|
// This is for Lua. See scripts/make_luals_meta.py
|
||||||
|
@ -55,7 +49,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit Channel(const QString &name, Type type);
|
explicit Channel(const QString &name, Type type);
|
||||||
virtual ~Channel();
|
~Channel() override;
|
||||||
|
|
||||||
// SIGNALS
|
// SIGNALS
|
||||||
pajlada::Signals::Signal<const QString &, const QString &, bool &>
|
pajlada::Signals::Signal<const QString &, const QString &, bool &>
|
||||||
|
@ -85,8 +79,9 @@ public:
|
||||||
// overridingFlags can be filled in with flags that should be used instead
|
// overridingFlags can be filled in with flags that should be used instead
|
||||||
// of the message's flags. This is useful in case a flag is specific to a
|
// of the message's flags. This is useful in case a flag is specific to a
|
||||||
// type of split
|
// type of split
|
||||||
void addMessage(MessagePtr message, MessageContext context,
|
void addMessage(
|
||||||
std::optional<MessageFlags> overridingFlags = std::nullopt);
|
MessagePtr message, MessageContext context,
|
||||||
|
std::optional<MessageFlags> overridingFlags = std::nullopt) final;
|
||||||
void addMessagesAtStart(const std::vector<MessagePtr> &messages_);
|
void addMessagesAtStart(const std::vector<MessagePtr> &messages_);
|
||||||
|
|
||||||
void addSystemMessage(const QString &contents);
|
void addSystemMessage(const QString &contents);
|
||||||
|
@ -94,8 +89,8 @@ public:
|
||||||
/// Inserts the given messages in order by Message::serverReceivedTime.
|
/// Inserts the given messages in order by Message::serverReceivedTime.
|
||||||
void fillInMissingMessages(const std::vector<MessagePtr> &messages);
|
void fillInMissingMessages(const std::vector<MessagePtr> &messages);
|
||||||
|
|
||||||
void addOrReplaceTimeout(MessagePtr message);
|
void addOrReplaceTimeout(MessagePtr message, QTime now) final;
|
||||||
void disableAllMessages();
|
void disableAllMessages() final;
|
||||||
void replaceMessage(MessagePtr message, MessagePtr replacement);
|
void replaceMessage(MessagePtr message, MessagePtr replacement);
|
||||||
void replaceMessage(size_t index, MessagePtr replacement);
|
void replaceMessage(size_t index, MessagePtr replacement);
|
||||||
void deleteMessage(QString messageID);
|
void deleteMessage(QString messageID);
|
||||||
|
@ -104,9 +99,14 @@ public:
|
||||||
void clearMessages();
|
void clearMessages();
|
||||||
|
|
||||||
MessagePtr findMessage(QString messageID);
|
MessagePtr findMessage(QString messageID);
|
||||||
|
MessagePtr findMessageByID(QStringView messageID) final;
|
||||||
|
|
||||||
bool hasMessages() const;
|
bool hasMessages() const;
|
||||||
|
|
||||||
|
void applySimilarityFilters(const MessagePtr &message) const final;
|
||||||
|
|
||||||
|
MessageSinkTraits sinkTraits() const final;
|
||||||
|
|
||||||
// CHANNEL INFO
|
// CHANNEL INFO
|
||||||
virtual bool canSendMessage() const;
|
virtual bool canSendMessage() const;
|
||||||
virtual bool isWritable() const; // whether split input will be usable
|
virtual bool isWritable() const; // whether split input will be usable
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
enum class ProviderId { Twitch, Irc };
|
enum class ProviderId { // NOLINT(performance-enum-size)
|
||||||
|
Twitch,
|
||||||
|
};
|
||||||
//
|
//
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -87,7 +87,8 @@ public:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(index >= 0 && index <= this->items_.size());
|
assert(index >= 0 &&
|
||||||
|
index <= static_cast<int>(this->items_.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
this->items_.insert(this->items_.begin() + index, item);
|
this->items_.insert(this->items_.begin() + index, item);
|
||||||
|
@ -116,7 +117,7 @@ public:
|
||||||
void removeAt(int index, void *caller = nullptr)
|
void removeAt(int index, void *caller = nullptr)
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
assert(index >= 0 && index < int(this->items_.size()));
|
assert(index >= 0 && index < static_cast<int>(this->items_.size()));
|
||||||
|
|
||||||
T item = this->items_[index];
|
T item = this->items_[index];
|
||||||
this->items_.erase(this->items_.begin() + index);
|
this->items_.erase(this->items_.begin() + index);
|
||||||
|
@ -132,13 +133,14 @@ public:
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
|
||||||
for (int index = 0; index < this->items_.size(); ++index)
|
for (size_t index = 0; index < this->items_.size(); ++index)
|
||||||
{
|
{
|
||||||
T item = this->items_[index];
|
T item = this->items_[index];
|
||||||
if (matcher(item))
|
if (matcher(item))
|
||||||
{
|
{
|
||||||
this->items_.erase(this->items_.begin() + index);
|
this->items_.erase(this->items_.begin() + index);
|
||||||
SignalVectorItemEvent<T> args{item, index, caller};
|
SignalVectorItemEvent<T> args{item, static_cast<int>(index),
|
||||||
|
caller};
|
||||||
this->itemRemoved.invoke(args);
|
this->itemRemoved.invoke(args);
|
||||||
this->itemsChanged_();
|
this->itemsChanged_();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
}
|
}
|
||||||
// get row index
|
// get row index
|
||||||
int index = this->getModelIndexFromVectorIndex(args.index);
|
int index = this->getModelIndexFromVectorIndex(args.index);
|
||||||
assert(index >= 0 && index <= this->rows_.size());
|
assert(index >= 0 && index <= static_cast<int>(this->rows_.size()));
|
||||||
|
|
||||||
// get row items
|
// get row items
|
||||||
std::vector<QStandardItem *> row = this->createRow();
|
std::vector<QStandardItem *> row = this->createRow();
|
||||||
|
@ -75,7 +75,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
int row = this->getModelIndexFromVectorIndex(args.index);
|
int row = this->getModelIndexFromVectorIndex(args.index);
|
||||||
assert(row >= 0 && row <= this->rows_.size());
|
assert(row >= 0 && row <= static_cast<int>(this->rows_.size()));
|
||||||
|
|
||||||
// remove row
|
// remove row
|
||||||
std::vector<QStandardItem *> items = this->rows_[row].items;
|
std::vector<QStandardItem *> items = this->rows_[row].items;
|
||||||
|
@ -130,7 +130,8 @@ public:
|
||||||
{
|
{
|
||||||
int row = index.row();
|
int row = index.row();
|
||||||
int column = index.column();
|
int column = index.column();
|
||||||
if (row < 0 || column < 0 || row >= this->rows_.size() ||
|
if (row < 0 || column < 0 ||
|
||||||
|
row >= static_cast<int>(this->rows_.size()) ||
|
||||||
column >= this->columnCount_)
|
column >= this->columnCount_)
|
||||||
{
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -144,7 +145,8 @@ public:
|
||||||
{
|
{
|
||||||
int row = index.row();
|
int row = index.row();
|
||||||
int column = index.column();
|
int column = index.column();
|
||||||
if (row < 0 || column < 0 || row >= this->rows_.size() ||
|
if (row < 0 || column < 0 ||
|
||||||
|
row >= static_cast<int>(this->rows_.size()) ||
|
||||||
column >= this->columnCount_)
|
column >= this->columnCount_)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -152,7 +154,7 @@ public:
|
||||||
|
|
||||||
Row &rowItem = this->rows_[row];
|
Row &rowItem = this->rows_[row];
|
||||||
|
|
||||||
assert(this->columnCount_ == rowItem.items.size());
|
assert(this->columnCount_ == static_cast<int>(rowItem.items.size()));
|
||||||
|
|
||||||
auto &cell = rowItem.items[column];
|
auto &cell = rowItem.items[column];
|
||||||
|
|
||||||
|
@ -167,7 +169,7 @@ public:
|
||||||
int vecRow = this->getVectorIndexFromModelIndex(row);
|
int vecRow = this->getVectorIndexFromModelIndex(row);
|
||||||
// TODO: This is only a safety-thing for when we modify data that's being modified right now.
|
// TODO: This is only a safety-thing for when we modify data that's being modified right now.
|
||||||
// It should not be necessary, but it would require some rethinking about this surrounding logic
|
// It should not be necessary, but it would require some rethinking about this surrounding logic
|
||||||
if (vecRow >= this->vector_->readOnly()->size())
|
if (vecRow >= static_cast<int>(this->vector_->readOnly()->size()))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -224,18 +226,19 @@ public:
|
||||||
{
|
{
|
||||||
int row = index.row(), column = index.column();
|
int row = index.row(), column = index.column();
|
||||||
|
|
||||||
if (row < 0 || column < 0 || row >= this->rows_.size() ||
|
if (row < 0 || column < 0 ||
|
||||||
|
row >= static_cast<int>(this->rows_.size()) ||
|
||||||
column >= this->columnCount_)
|
column >= this->columnCount_)
|
||||||
{
|
{
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(row >= 0 && row < this->rows_.size() && column >= 0 &&
|
assert(row >= 0 && row < static_cast<int>(this->rows_.size()) &&
|
||||||
column < this->columnCount_);
|
column >= 0 && column < this->columnCount_);
|
||||||
|
|
||||||
const auto &rowItem = this->rows_[row];
|
const auto &rowItem = this->rows_[row];
|
||||||
|
|
||||||
assert(this->columnCount_ == rowItem.items.size());
|
assert(this->columnCount_ == static_cast<int>(rowItem.items.size()));
|
||||||
|
|
||||||
return rowItem.items[column]->flags();
|
return rowItem.items[column]->flags();
|
||||||
}
|
}
|
||||||
|
@ -267,7 +270,8 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(sourceRow >= 0 && sourceRow < this->rows_.size());
|
assert(sourceRow >= 0 &&
|
||||||
|
sourceRow < static_cast<int>(this->rows_.size()));
|
||||||
|
|
||||||
int signalVectorRow = this->getVectorIndexFromModelIndex(sourceRow);
|
int signalVectorRow = this->getVectorIndexFromModelIndex(sourceRow);
|
||||||
this->beginMoveRows(sourceParent, sourceRow, sourceRow,
|
this->beginMoveRows(sourceParent, sourceRow, sourceRow,
|
||||||
|
@ -294,7 +298,7 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(row >= 0 && row < this->rows_.size());
|
assert(row >= 0 && row < static_cast<int>(this->rows_.size()));
|
||||||
|
|
||||||
int signalVectorRow = this->getVectorIndexFromModelIndex(row);
|
int signalVectorRow = this->getVectorIndexFromModelIndex(row);
|
||||||
this->vector_->removeAt(signalVectorRow);
|
this->vector_->removeAt(signalVectorRow);
|
||||||
|
@ -337,8 +341,10 @@ public:
|
||||||
int from = data->data("chatterino_row_id").toInt();
|
int from = data->data("chatterino_row_id").toInt();
|
||||||
int to = parent.row();
|
int to = parent.row();
|
||||||
|
|
||||||
int vectorFrom = this->getVectorIndexFromModelIndex(from);
|
auto vectorFrom =
|
||||||
int vectorTo = this->getVectorIndexFromModelIndex(to);
|
static_cast<size_t>(this->getVectorIndexFromModelIndex(from));
|
||||||
|
auto vectorTo =
|
||||||
|
static_cast<size_t>(this->getVectorIndexFromModelIndex(to));
|
||||||
|
|
||||||
if (vectorFrom < 0 || vectorFrom > this->vector_->raw().size() ||
|
if (vectorFrom < 0 || vectorFrom > this->vector_->raw().size() ||
|
||||||
vectorTo < 0 || vectorTo > this->vector_->raw().size())
|
vectorTo < 0 || vectorTo > this->vector_->raw().size())
|
||||||
|
@ -402,7 +408,7 @@ protected:
|
||||||
|
|
||||||
void insertCustomRow(std::vector<QStandardItem *> row, int index)
|
void insertCustomRow(std::vector<QStandardItem *> row, int index)
|
||||||
{
|
{
|
||||||
assert(index >= 0 && index <= this->rows_.size());
|
assert(index >= 0 && index <= static_cast<int>(this->rows_.size()));
|
||||||
|
|
||||||
this->beginInsertRows(QModelIndex(), index, index);
|
this->beginInsertRows(QModelIndex(), index, index);
|
||||||
this->rows_.insert(this->rows_.begin() + index,
|
this->rows_.insert(this->rows_.begin() + index,
|
||||||
|
@ -412,7 +418,7 @@ protected:
|
||||||
|
|
||||||
void removeCustomRow(int index)
|
void removeCustomRow(int index)
|
||||||
{
|
{
|
||||||
assert(index >= 0 && index <= this->rows_.size());
|
assert(index >= 0 && index <= static_cast<int>(this->rows_.size()));
|
||||||
assert(this->rows_[index].isCustomRow);
|
assert(this->rows_[index].isCustomRow);
|
||||||
|
|
||||||
this->beginRemoveRows(QModelIndex(), index, index);
|
this->beginRemoveRows(QModelIndex(), index, index);
|
||||||
|
|
13
src/common/enums/MessageContext.hpp
Normal file
13
src/common/enums/MessageContext.hpp
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
/// Context of the message being added to a channel
|
||||||
|
enum class MessageContext {
|
||||||
|
/// This message is the original
|
||||||
|
Original,
|
||||||
|
/// This message is a repost of a message that has already been added in a channel
|
||||||
|
Repost,
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace chatterino
|
|
@ -37,7 +37,7 @@ void UnifiedSource::addToListModel(GenericListModel &model,
|
||||||
source->addToListModel(model, maxCount - used);
|
source->addToListModel(model, maxCount - used);
|
||||||
// Calculate how many items have been added so far
|
// Calculate how many items have been added so far
|
||||||
used = model.rowCount() - startingSize;
|
used = model.rowCount() - startingSize;
|
||||||
if (used >= maxCount)
|
if (used >= static_cast<int>(maxCount))
|
||||||
{
|
{
|
||||||
// Used up all of limit
|
// Used up all of limit
|
||||||
break;
|
break;
|
||||||
|
@ -58,15 +58,15 @@ void UnifiedSource::addToStringList(QStringList &list, size_t maxCount,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure to only add maxCount elements in total.
|
// Make sure to only add maxCount elements in total.
|
||||||
int startingSize = list.size();
|
auto startingSize = list.size();
|
||||||
int used = 0;
|
QStringList::size_type used = 0;
|
||||||
|
|
||||||
for (const auto &source : this->sources_)
|
for (const auto &source : this->sources_)
|
||||||
{
|
{
|
||||||
source->addToStringList(list, maxCount - used, isFirstWord);
|
source->addToStringList(list, maxCount - used, isFirstWord);
|
||||||
// Calculate how many items have been added so far
|
// Calculate how many items have been added so far
|
||||||
used = list.size() - startingSize;
|
used = list.size() - startingSize;
|
||||||
if (used >= maxCount)
|
if (used >= static_cast<QStringList::size_type>(maxCount))
|
||||||
{
|
{
|
||||||
// Used up all of limit
|
// Used up all of limit
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -196,12 +196,12 @@ public:
|
||||||
std::unique_lock lock(this->mutex_);
|
std::unique_lock lock(this->mutex_);
|
||||||
|
|
||||||
Equals eq;
|
Equals eq;
|
||||||
for (int i = 0; i < this->buffer_.size(); ++i)
|
for (size_t i = 0; i < this->buffer_.size(); ++i)
|
||||||
{
|
{
|
||||||
if (eq(this->buffer_[i], needle))
|
if (eq(this->buffer_[i], needle))
|
||||||
{
|
{
|
||||||
this->buffer_[i] = replacement;
|
this->buffer_[i] = replacement;
|
||||||
return i;
|
return static_cast<int>(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -116,7 +116,7 @@ QString formatUpdatedEmoteList(const QString &platform,
|
||||||
text += QString(" %1 %2 emotes ").arg(emoteNames.size()).arg(platform);
|
text += QString(" %1 %2 emotes ").arg(emoteNames.size()).arg(platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto i = 0;
|
size_t i = 0;
|
||||||
for (const auto &emoteName : emoteNames)
|
for (const auto &emoteName : emoteNames)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
|
|
121
src/messages/MessageSimilarity.cpp
Normal file
121
src/messages/MessageSimilarity.cpp
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
#include "messages/MessageSimilarity.hpp"
|
||||||
|
|
||||||
|
#include "Application.hpp"
|
||||||
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
|
#include "messages/LimitedQueueSnapshot.hpp" // IWYU pragma: keep
|
||||||
|
#include "providers/twitch/TwitchAccount.hpp"
|
||||||
|
#include "singletons/Settings.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
using namespace chatterino;
|
||||||
|
|
||||||
|
float relativeSimilarity(QStringView str1, QStringView str2)
|
||||||
|
{
|
||||||
|
using SizeType = QStringView::size_type;
|
||||||
|
|
||||||
|
// Longest Common Substring Problem
|
||||||
|
std::vector<std::vector<int>> tree(str1.size(),
|
||||||
|
std::vector<int>(str2.size(), 0));
|
||||||
|
int z = 0;
|
||||||
|
|
||||||
|
for (SizeType i = 0; i < str1.size(); ++i)
|
||||||
|
{
|
||||||
|
for (SizeType j = 0; j < str2.size(); ++j)
|
||||||
|
{
|
||||||
|
if (str1[i] == str2[j])
|
||||||
|
{
|
||||||
|
if (i == 0 || j == 0)
|
||||||
|
{
|
||||||
|
tree[i][j] = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tree[i][j] = tree[i - 1][j - 1] + 1;
|
||||||
|
}
|
||||||
|
z = std::max(tree[i][j], z);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tree[i][j] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ensure that no div by 0
|
||||||
|
if (z == 0)
|
||||||
|
{
|
||||||
|
return 0.F;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto div = std::max<>({static_cast<SizeType>(1), str1.size(), str2.size()});
|
||||||
|
|
||||||
|
return float(z) / float(div);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::ranges::bidirectional_range T>
|
||||||
|
float inMessages(const MessagePtr &msg, const T &messages)
|
||||||
|
{
|
||||||
|
float similarityPercent = 0.0F;
|
||||||
|
|
||||||
|
for (const auto &prevMsg :
|
||||||
|
messages | std::views::reverse |
|
||||||
|
std::views::take(getSettings()->hideSimilarMaxMessagesToCheck))
|
||||||
|
{
|
||||||
|
if (prevMsg->parseTime.secsTo(QTime::currentTime()) >=
|
||||||
|
getSettings()->hideSimilarMaxDelay)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (getSettings()->hideSimilarBySameUser &&
|
||||||
|
msg->loginName != prevMsg->loginName)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
similarityPercent = std::max(
|
||||||
|
similarityPercent,
|
||||||
|
relativeSimilarity(msg->messageText, prevMsg->messageText));
|
||||||
|
}
|
||||||
|
|
||||||
|
return similarityPercent;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
template <std::ranges::bidirectional_range T>
|
||||||
|
void setSimilarityFlags(const MessagePtr &message, const T &messages)
|
||||||
|
{
|
||||||
|
if (getSettings()->similarityEnabled)
|
||||||
|
{
|
||||||
|
bool isMyself =
|
||||||
|
message->loginName ==
|
||||||
|
getApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
||||||
|
bool hideMyself = getSettings()->hideSimilarMyself;
|
||||||
|
|
||||||
|
if (isMyself && !hideMyself)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inMessages(message, messages) > getSettings()->similarityPercentage)
|
||||||
|
{
|
||||||
|
message->flags.set(MessageFlag::Similar);
|
||||||
|
if (getSettings()->colorSimilarDisabled)
|
||||||
|
{
|
||||||
|
message->flags.set(MessageFlag::Disabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template void setSimilarityFlags<std::vector<MessagePtr>>(
|
||||||
|
const MessagePtr &msg, const std::vector<MessagePtr> &messages);
|
||||||
|
template void setSimilarityFlags<LimitedQueueSnapshot<MessagePtr>>(
|
||||||
|
const MessagePtr &msg, const LimitedQueueSnapshot<MessagePtr> &messages);
|
||||||
|
|
||||||
|
} // namespace chatterino
|
11
src/messages/MessageSimilarity.hpp
Normal file
11
src/messages/MessageSimilarity.hpp
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "messages/Message.hpp"
|
||||||
|
|
||||||
|
#include <ranges>
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
template <std::ranges::bidirectional_range T>
|
||||||
|
void setSimilarityFlags(const MessagePtr &message, const T &messages);
|
||||||
|
|
||||||
|
} // namespace chatterino
|
66
src/messages/MessageSink.hpp
Normal file
66
src/messages/MessageSink.hpp
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/enums/MessageContext.hpp"
|
||||||
|
#include "common/FlagsEnum.hpp"
|
||||||
|
#include "messages/MessageFlag.hpp"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
class QStringView;
|
||||||
|
class QTime;
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
struct Message;
|
||||||
|
using MessagePtr = std::shared_ptr<const Message>;
|
||||||
|
|
||||||
|
enum class MessageSinkTrait : uint8_t {
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
/// Messages with the `Highlighted` and `ShowInMentions` flags should be
|
||||||
|
/// added to the global mentions channel when encountered.
|
||||||
|
AddMentionsToGlobalChannel = 1 << 0,
|
||||||
|
|
||||||
|
/// A channel-point redemption whose reward is not yet known should not be
|
||||||
|
/// added to this sink, but queued in the corresponding TwitchChannel
|
||||||
|
/// (`addQueuedRedemption`).
|
||||||
|
RequiresKnownChannelPointReward = 1 << 1,
|
||||||
|
};
|
||||||
|
using MessageSinkTraits = FlagsEnum<MessageSinkTrait>;
|
||||||
|
|
||||||
|
/// A generic interface for a managed buffer of `Message`s
|
||||||
|
class MessageSink
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~MessageSink() = default;
|
||||||
|
|
||||||
|
/// Add a message to this sink
|
||||||
|
///
|
||||||
|
/// @param message The message to add (non-null)
|
||||||
|
/// @param ctx The context in which this message is being added.
|
||||||
|
/// @param overridingFlags
|
||||||
|
virtual void addMessage(
|
||||||
|
MessagePtr message, MessageContext ctx,
|
||||||
|
std::optional<MessageFlags> overridingFlags = std::nullopt) = 0;
|
||||||
|
|
||||||
|
/// Adds a timeout message or merges it into an existing one
|
||||||
|
virtual void addOrReplaceTimeout(MessagePtr clearchatMessage,
|
||||||
|
QTime now) = 0;
|
||||||
|
|
||||||
|
/// Flags all messages as `Disabled`
|
||||||
|
virtual void disableAllMessages() = 0;
|
||||||
|
|
||||||
|
/// Searches for similar messages and flags this message as similar
|
||||||
|
/// (based on the current settings).
|
||||||
|
virtual void applySimilarityFilters(const MessagePtr &message) const = 0;
|
||||||
|
|
||||||
|
/// @brief Searches for a message by an ID
|
||||||
|
///
|
||||||
|
/// If there is no message found, an empty shared-pointer is returned.
|
||||||
|
virtual MessagePtr findMessageByID(QStringView id) = 0;
|
||||||
|
|
||||||
|
/// Behaviour to be exercised when parsing/building messages for this sink.
|
||||||
|
virtual MessageSinkTraits sinkTraits() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace chatterino
|
|
@ -212,7 +212,8 @@ void MessageLayoutContainer::breakLine()
|
||||||
this->lineStart_ = this->elements_.size();
|
this->lineStart_ = this->elements_.size();
|
||||||
// this->currentX = (int)(this->scale * 8);
|
// this->currentX = (int)(this->scale * 8);
|
||||||
|
|
||||||
if (this->canCollapse() && this->line_ + 1 >= maxUncollapsedLines())
|
if (this->canCollapse() &&
|
||||||
|
static_cast<int>(this->line_ + 1) >= maxUncollapsedLines())
|
||||||
{
|
{
|
||||||
this->canAddMessages_ = false;
|
this->canAddMessages_ = false;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -514,9 +514,10 @@ int TextLayoutElement::getXFromIndex(size_t index)
|
||||||
else if (index < static_cast<size_t>(this->getText().size()))
|
else if (index < static_cast<size_t>(this->getText().size()))
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
for (int i = 0; i < index; i++)
|
for (size_t i = 0; i < index; i++)
|
||||||
{
|
{
|
||||||
x += metrics.horizontalAdvance(this->getText()[i]);
|
x += metrics.horizontalAdvance(
|
||||||
|
this->getText()[static_cast<QString::size_type>(i)]);
|
||||||
}
|
}
|
||||||
return x + this->getRect().left();
|
return x + this->getRect().left();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
#include "common/Env.hpp"
|
#include "common/Env.hpp"
|
||||||
#include "messages/MessageBuilder.hpp"
|
#include "messages/MessageBuilder.hpp"
|
||||||
#include "providers/twitch/IrcMessageHandler.hpp"
|
#include "providers/twitch/IrcMessageHandler.hpp"
|
||||||
|
#include "providers/twitch/TwitchChannel.hpp"
|
||||||
#include "util/Helpers.hpp"
|
#include "util/Helpers.hpp"
|
||||||
|
#include "util/VectorMessageSink.hpp"
|
||||||
|
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
|
@ -40,7 +42,13 @@ std::vector<Communi::IrcMessage *> parseRecentMessages(
|
||||||
std::vector<MessagePtr> buildRecentMessages(
|
std::vector<MessagePtr> buildRecentMessages(
|
||||||
std::vector<Communi::IrcMessage *> &messages, Channel *channel)
|
std::vector<Communi::IrcMessage *> &messages, Channel *channel)
|
||||||
{
|
{
|
||||||
std::vector<MessagePtr> allBuiltMessages;
|
VectorMessageSink sink({}, MessageFlag::RecentMessage);
|
||||||
|
|
||||||
|
auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel);
|
||||||
|
if (!twitchChannel)
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
for (auto *message : messages)
|
for (auto *message : messages)
|
||||||
{
|
{
|
||||||
|
@ -58,24 +66,16 @@ std::vector<MessagePtr> buildRecentMessages(
|
||||||
auto msg = makeSystemMessage(
|
auto msg = makeSystemMessage(
|
||||||
QLocale().toString(msgDate, QLocale::LongFormat),
|
QLocale().toString(msgDate, QLocale::LongFormat),
|
||||||
QTime(0, 0));
|
QTime(0, 0));
|
||||||
msg->flags.set(MessageFlag::RecentMessage);
|
sink.addMessage(msg, MessageContext::Original);
|
||||||
allBuiltMessages.emplace_back(msg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto builtMessages = IrcMessageHandler::parseMessageWithReply(
|
IrcMessageHandler::parseMessageInto(message, sink, twitchChannel);
|
||||||
channel, message, allBuiltMessages);
|
|
||||||
|
|
||||||
for (const auto &builtMessage : builtMessages)
|
|
||||||
{
|
|
||||||
builtMessage->flags.set(MessageFlag::RecentMessage);
|
|
||||||
allBuiltMessages.emplace_back(builtMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
message->deleteLater();
|
message->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
return allBuiltMessages;
|
return std::move(sink).takeMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the URL to be used for querying the Recent Messages API for the
|
// Returns the URL to be used for querying the Recent Messages API for the
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -16,6 +16,7 @@ struct Message;
|
||||||
using MessagePtr = std::shared_ptr<const Message>;
|
using MessagePtr = std::shared_ptr<const Message>;
|
||||||
class TwitchChannel;
|
class TwitchChannel;
|
||||||
class TwitchMessageBuilder;
|
class TwitchMessageBuilder;
|
||||||
|
class MessageSink;
|
||||||
|
|
||||||
struct ClearChatMessage {
|
struct ClearChatMessage {
|
||||||
MessagePtr message;
|
MessagePtr message;
|
||||||
|
@ -33,30 +34,35 @@ public:
|
||||||
* Parse an IRC message into 0 or more Chatterino messages
|
* Parse an IRC message into 0 or more Chatterino messages
|
||||||
* Takes previously loaded messages into consideration to add reply contexts
|
* Takes previously loaded messages into consideration to add reply contexts
|
||||||
**/
|
**/
|
||||||
static std::vector<MessagePtr> parseMessageWithReply(
|
static void parseMessageInto(Communi::IrcMessage *message,
|
||||||
Channel *channel, Communi::IrcMessage *message,
|
MessageSink &sink, TwitchChannel *channel);
|
||||||
std::vector<MessagePtr> &otherLoaded);
|
|
||||||
|
|
||||||
void handlePrivMessage(Communi::IrcPrivateMessage *message,
|
void handlePrivMessage(Communi::IrcPrivateMessage *message,
|
||||||
ITwitchIrcServer &twitchServer);
|
ITwitchIrcServer &twitchServer);
|
||||||
|
static void parsePrivMessageInto(Communi::IrcPrivateMessage *message,
|
||||||
|
MessageSink &sink, TwitchChannel *channel);
|
||||||
|
|
||||||
void handleRoomStateMessage(Communi::IrcMessage *message);
|
void handleRoomStateMessage(Communi::IrcMessage *message);
|
||||||
void handleClearChatMessage(Communi::IrcMessage *message);
|
void handleClearChatMessage(Communi::IrcMessage *message);
|
||||||
void handleClearMessageMessage(Communi::IrcMessage *message);
|
void handleClearMessageMessage(Communi::IrcMessage *message);
|
||||||
void handleUserStateMessage(Communi::IrcMessage *message);
|
void handleUserStateMessage(Communi::IrcMessage *message);
|
||||||
void handleWhisperMessage(Communi::IrcMessage *ircMessage);
|
|
||||||
|
|
||||||
|
void handleWhisperMessage(Communi::IrcMessage *ircMessage);
|
||||||
void handleUserNoticeMessage(Communi::IrcMessage *message,
|
void handleUserNoticeMessage(Communi::IrcMessage *message,
|
||||||
ITwitchIrcServer &twitchServer);
|
ITwitchIrcServer &twitchServer);
|
||||||
|
static void parseUserNoticeMessageInto(Communi::IrcMessage *message,
|
||||||
|
MessageSink &sink,
|
||||||
|
TwitchChannel *channel);
|
||||||
|
|
||||||
void handleNoticeMessage(Communi::IrcNoticeMessage *message);
|
void handleNoticeMessage(Communi::IrcNoticeMessage *message);
|
||||||
|
|
||||||
void handleJoinMessage(Communi::IrcMessage *message);
|
void handleJoinMessage(Communi::IrcMessage *message);
|
||||||
void handlePartMessage(Communi::IrcMessage *message);
|
void handlePartMessage(Communi::IrcMessage *message);
|
||||||
|
|
||||||
void addMessage(Communi::IrcMessage *message, const ChannelPtr &chan,
|
static void addMessage(Communi::IrcMessage *message, MessageSink &sink,
|
||||||
const QString &originalContent, ITwitchIrcServer &server,
|
TwitchChannel *channel,
|
||||||
bool isSub, bool isAction);
|
const QString &originalContent, bool isSub,
|
||||||
|
bool isAction);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static float similarity(const MessagePtr &msg,
|
static float similarity(const MessagePtr &msg,
|
||||||
|
|
|
@ -452,8 +452,8 @@ void TwitchChannel::addChannelPointReward(const ChannelPointReward &reward)
|
||||||
if (reward.id == msg.rewardID)
|
if (reward.id == msg.rewardID)
|
||||||
{
|
{
|
||||||
IrcMessageHandler::instance().addMessage(
|
IrcMessageHandler::instance().addMessage(
|
||||||
msg.message.get(), shared_from_this(),
|
msg.message.get(), *this, this, msg.originalContent,
|
||||||
msg.originalContent, *server, false, false);
|
false, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1356,8 +1356,6 @@ void TwitchChannel::loadRecentMessages()
|
||||||
{
|
{
|
||||||
msgs.push_back(msg);
|
msgs.push_back(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
tc->addRecentChatter(msg->displayName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getApp()->getTwitch()->getMentionsChannel()->fillInMissingMessages(
|
getApp()->getTwitch()->getMentionsChannel()->fillInMissingMessages(
|
||||||
|
|
|
@ -312,7 +312,7 @@ void TwitchIrcServer::initialize()
|
||||||
postToThread([chan, action] {
|
postToThread([chan, action] {
|
||||||
MessageBuilder msg(action);
|
MessageBuilder msg(action);
|
||||||
msg->flags.set(MessageFlag::PubSub);
|
msg->flags.set(MessageFlag::PubSub);
|
||||||
chan->addOrReplaceTimeout(msg.release());
|
chan->addOrReplaceTimeout(msg.release(), QTime::currentTime());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1909,7 +1909,7 @@ void Helix::updateChatSettings(
|
||||||
|
|
||||||
void Helix::onFetchChattersSuccess(
|
void Helix::onFetchChattersSuccess(
|
||||||
std::shared_ptr<HelixChatters> finalChatters, QString broadcasterID,
|
std::shared_ptr<HelixChatters> finalChatters, QString broadcasterID,
|
||||||
QString moderatorID, int maxChattersToFetch,
|
QString moderatorID, size_t maxChattersToFetch,
|
||||||
ResultCallback<HelixChatters> successCallback,
|
ResultCallback<HelixChatters> successCallback,
|
||||||
FailureCallback<HelixGetChattersError, QString> failureCallback,
|
FailureCallback<HelixGetChattersError, QString> failureCallback,
|
||||||
HelixChatters chatters)
|
HelixChatters chatters)
|
||||||
|
@ -2022,7 +2022,7 @@ void Helix::fetchChatters(
|
||||||
|
|
||||||
void Helix::onFetchModeratorsSuccess(
|
void Helix::onFetchModeratorsSuccess(
|
||||||
std::shared_ptr<std::vector<HelixModerator>> finalModerators,
|
std::shared_ptr<std::vector<HelixModerator>> finalModerators,
|
||||||
QString broadcasterID, int maxModeratorsToFetch,
|
QString broadcasterID, size_t maxModeratorsToFetch,
|
||||||
ResultCallback<std::vector<HelixModerator>> successCallback,
|
ResultCallback<std::vector<HelixModerator>> successCallback,
|
||||||
FailureCallback<HelixGetModeratorsError, QString> failureCallback,
|
FailureCallback<HelixGetModeratorsError, QString> failureCallback,
|
||||||
HelixModerators moderators)
|
HelixModerators moderators)
|
||||||
|
@ -2459,7 +2459,7 @@ void Helix::sendWhisper(
|
||||||
|
|
||||||
// https://dev.twitch.tv/docs/api/reference#get-chatters
|
// https://dev.twitch.tv/docs/api/reference#get-chatters
|
||||||
void Helix::getChatters(
|
void Helix::getChatters(
|
||||||
QString broadcasterID, QString moderatorID, int maxChattersToFetch,
|
QString broadcasterID, QString moderatorID, size_t maxChattersToFetch,
|
||||||
ResultCallback<HelixChatters> successCallback,
|
ResultCallback<HelixChatters> successCallback,
|
||||||
FailureCallback<HelixGetChattersError, QString> failureCallback)
|
FailureCallback<HelixGetChattersError, QString> failureCallback)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1073,7 +1073,7 @@ public:
|
||||||
// This will follow the returned cursor and return up to `maxChattersToFetch` chatters
|
// This will follow the returned cursor and return up to `maxChattersToFetch` chatters
|
||||||
// https://dev.twitch.tv/docs/api/reference#get-chatters
|
// https://dev.twitch.tv/docs/api/reference#get-chatters
|
||||||
virtual void getChatters(
|
virtual void getChatters(
|
||||||
QString broadcasterID, QString moderatorID, int maxChattersToFetch,
|
QString broadcasterID, QString moderatorID, size_t maxChattersToFetch,
|
||||||
ResultCallback<HelixChatters> successCallback,
|
ResultCallback<HelixChatters> successCallback,
|
||||||
FailureCallback<HelixGetChattersError, QString> failureCallback) = 0;
|
FailureCallback<HelixGetChattersError, QString> failureCallback) = 0;
|
||||||
|
|
||||||
|
@ -1417,7 +1417,7 @@ public:
|
||||||
// This will follow the returned cursor and return up to `maxChattersToFetch` chatters
|
// This will follow the returned cursor and return up to `maxChattersToFetch` chatters
|
||||||
// https://dev.twitch.tv/docs/api/reference#get-chatters
|
// https://dev.twitch.tv/docs/api/reference#get-chatters
|
||||||
void getChatters(
|
void getChatters(
|
||||||
QString broadcasterID, QString moderatorID, int maxChattersToFetch,
|
QString broadcasterID, QString moderatorID, size_t maxChattersToFetch,
|
||||||
ResultCallback<HelixChatters> successCallback,
|
ResultCallback<HelixChatters> successCallback,
|
||||||
FailureCallback<HelixGetChattersError, QString> failureCallback) final;
|
FailureCallback<HelixGetChattersError, QString> failureCallback) final;
|
||||||
|
|
||||||
|
@ -1505,7 +1505,7 @@ protected:
|
||||||
// Recursive boy
|
// Recursive boy
|
||||||
void onFetchChattersSuccess(
|
void onFetchChattersSuccess(
|
||||||
std::shared_ptr<HelixChatters> finalChatters, QString broadcasterID,
|
std::shared_ptr<HelixChatters> finalChatters, QString broadcasterID,
|
||||||
QString moderatorID, int maxChattersToFetch,
|
QString moderatorID, size_t maxChattersToFetch,
|
||||||
ResultCallback<HelixChatters> successCallback,
|
ResultCallback<HelixChatters> successCallback,
|
||||||
FailureCallback<HelixGetChattersError, QString> failureCallback,
|
FailureCallback<HelixGetChattersError, QString> failureCallback,
|
||||||
HelixChatters chatters);
|
HelixChatters chatters);
|
||||||
|
@ -1520,7 +1520,7 @@ protected:
|
||||||
// Recursive boy
|
// Recursive boy
|
||||||
void onFetchModeratorsSuccess(
|
void onFetchModeratorsSuccess(
|
||||||
std::shared_ptr<std::vector<HelixModerator>> finalModerators,
|
std::shared_ptr<std::vector<HelixModerator>> finalModerators,
|
||||||
QString broadcasterID, int maxModeratorsToFetch,
|
QString broadcasterID, size_t maxModeratorsToFetch,
|
||||||
ResultCallback<std::vector<HelixModerator>> successCallback,
|
ResultCallback<std::vector<HelixModerator>> successCallback,
|
||||||
FailureCallback<HelixGetModeratorsError, QString> failureCallback,
|
FailureCallback<HelixGetModeratorsError, QString> failureCallback,
|
||||||
HelixModerators moderators);
|
HelixModerators moderators);
|
||||||
|
|
86
src/util/VectorMessageSink.cpp
Normal file
86
src/util/VectorMessageSink.cpp
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
#include "util/VectorMessageSink.hpp"
|
||||||
|
|
||||||
|
#include "messages/MessageSimilarity.hpp"
|
||||||
|
#include "util/ChannelHelpers.hpp"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
VectorMessageSink::VectorMessageSink(MessageSinkTraits traits,
|
||||||
|
MessageFlags additionalFlags)
|
||||||
|
: additionalFlags(additionalFlags)
|
||||||
|
, traits(traits){};
|
||||||
|
VectorMessageSink::~VectorMessageSink() = default;
|
||||||
|
|
||||||
|
void VectorMessageSink::addMessage(MessagePtr message, MessageContext ctx,
|
||||||
|
std::optional<MessageFlags> overridingFlags)
|
||||||
|
{
|
||||||
|
assert(!overridingFlags.has_value());
|
||||||
|
assert(ctx == MessageContext::Original);
|
||||||
|
|
||||||
|
message->flags.set(this->additionalFlags);
|
||||||
|
this->messages_.emplace_back(std::move(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VectorMessageSink::addOrReplaceTimeout(MessagePtr clearchatMessage,
|
||||||
|
QTime now)
|
||||||
|
{
|
||||||
|
addOrReplaceChannelTimeout(
|
||||||
|
this->messages_, std::move(clearchatMessage), now,
|
||||||
|
[&](auto idx, auto /*msg*/, auto &&replacement) {
|
||||||
|
replacement->flags.set(this->additionalFlags);
|
||||||
|
this->messages_[idx] = replacement;
|
||||||
|
},
|
||||||
|
[&](auto &&msg) {
|
||||||
|
this->messages_.emplace_back(msg);
|
||||||
|
},
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VectorMessageSink::disableAllMessages()
|
||||||
|
{
|
||||||
|
if (this->additionalFlags.has(MessageFlag::RecentMessage))
|
||||||
|
{
|
||||||
|
return; // don't disable recent messages
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &msg : this->messages_)
|
||||||
|
{
|
||||||
|
msg->flags.set(MessageFlag::Disabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VectorMessageSink::applySimilarityFilters(const MessagePtr &message) const
|
||||||
|
{
|
||||||
|
setSimilarityFlags(message, this->messages_);
|
||||||
|
}
|
||||||
|
|
||||||
|
MessagePtr VectorMessageSink::findMessageByID(QStringView id)
|
||||||
|
{
|
||||||
|
for (const auto &msg : this->messages_ | std::views::reverse)
|
||||||
|
{
|
||||||
|
if (msg->id == id)
|
||||||
|
{
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<MessagePtr> &VectorMessageSink::messages() const
|
||||||
|
{
|
||||||
|
return this->messages_;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<MessagePtr> VectorMessageSink::takeMessages() &&
|
||||||
|
{
|
||||||
|
return std::move(this->messages_);
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageSinkTraits VectorMessageSink::sinkTraits() const
|
||||||
|
{
|
||||||
|
return this->traits;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace chatterino
|
36
src/util/VectorMessageSink.hpp
Normal file
36
src/util/VectorMessageSink.hpp
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "messages/MessageSink.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
class VectorMessageSink final : public MessageSink
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VectorMessageSink(MessageSinkTraits traits = {},
|
||||||
|
MessageFlags additionalFlags = {});
|
||||||
|
~VectorMessageSink() override;
|
||||||
|
|
||||||
|
void addMessage(
|
||||||
|
MessagePtr message, MessageContext ctx,
|
||||||
|
std::optional<MessageFlags> overridingFlags = std::nullopt) override;
|
||||||
|
void addOrReplaceTimeout(MessagePtr clearchatMessage, QTime now) override;
|
||||||
|
|
||||||
|
void disableAllMessages() override;
|
||||||
|
|
||||||
|
void applySimilarityFilters(const MessagePtr &message) const override;
|
||||||
|
|
||||||
|
MessagePtr findMessageByID(QStringView id) override;
|
||||||
|
|
||||||
|
MessageSinkTraits sinkTraits() const override;
|
||||||
|
|
||||||
|
const std::vector<MessagePtr> &messages() const;
|
||||||
|
std::vector<MessagePtr> takeMessages() &&;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<MessagePtr> messages_;
|
||||||
|
MessageFlags additionalFlags;
|
||||||
|
MessageSinkTraits traits;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace chatterino
|
|
@ -119,9 +119,9 @@ void TooltipWidget::set(const std::vector<TooltipEntry> &entries,
|
||||||
|
|
||||||
this->setVisibleEntries(entries.size());
|
this->setVisibleEntries(entries.size());
|
||||||
|
|
||||||
for (int i = 0; i < entries.size(); ++i)
|
for (size_t i = 0; i < entries.size(); ++i)
|
||||||
{
|
{
|
||||||
if (auto *entryWidget = this->entryAt(i))
|
if (auto *entryWidget = this->entryAt(static_cast<int>(i)))
|
||||||
{
|
{
|
||||||
const auto &entry = entries[i];
|
const auto &entry = entries[i];
|
||||||
entryWidget->setImage(entry.image);
|
entryWidget->setImage(entry.image);
|
||||||
|
|
|
@ -79,7 +79,7 @@ void EditHotkeyDialog::setFromHotkey(std::shared_ptr<Hotkey> hotkey)
|
||||||
this->ui_->easyArgsLabel->setText(def->argumentsPrompt);
|
this->ui_->easyArgsLabel->setText(def->argumentsPrompt);
|
||||||
this->ui_->easyArgsLabel->setToolTip(def->argumentsPromptHover);
|
this->ui_->easyArgsLabel->setToolTip(def->argumentsPromptHover);
|
||||||
int matchIdx = -1;
|
int matchIdx = -1;
|
||||||
for (int i = 0; i < def->possibleArguments.size(); i++)
|
for (size_t i = 0; i < def->possibleArguments.size(); i++)
|
||||||
{
|
{
|
||||||
const auto &[displayText, argData] = def->possibleArguments.at(i);
|
const auto &[displayText, argData] = def->possibleArguments.at(i);
|
||||||
this->ui_->easyArgsPicker->addItem(displayText);
|
this->ui_->easyArgsPicker->addItem(displayText);
|
||||||
|
@ -90,7 +90,7 @@ void EditHotkeyDialog::setFromHotkey(std::shared_ptr<Hotkey> hotkey)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bool matches = true;
|
bool matches = true;
|
||||||
for (int j = 0; j < argData.size(); j++)
|
for (size_t j = 0; j < argData.size(); j++)
|
||||||
{
|
{
|
||||||
if (argData.at(j) != hotkey->arguments().at(j))
|
if (argData.at(j) != hotkey->arguments().at(j))
|
||||||
{
|
{
|
||||||
|
@ -100,7 +100,7 @@ void EditHotkeyDialog::setFromHotkey(std::shared_ptr<Hotkey> hotkey)
|
||||||
}
|
}
|
||||||
if (matches)
|
if (matches)
|
||||||
{
|
{
|
||||||
matchIdx = i;
|
matchIdx = static_cast<int>(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (matchIdx != -1)
|
if (matchIdx != -1)
|
||||||
|
|
|
@ -219,11 +219,13 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
|
||||||
|
|
||||||
const auto &timeoutButtons =
|
const auto &timeoutButtons =
|
||||||
getSettings()->timeoutButtons.getValue();
|
getSettings()->timeoutButtons.getValue();
|
||||||
if (timeoutButtons.size() < buttonNum || 0 >= buttonNum)
|
if (static_cast<int>(timeoutButtons.size()) < buttonNum ||
|
||||||
|
0 >= buttonNum)
|
||||||
{
|
{
|
||||||
return QString("Invalid argument for execModeratorAction: "
|
return QString("Invalid argument for execModeratorAction: "
|
||||||
"%1. Integer out of usable range: [1, %2]")
|
"%1. Integer out of usable range: [1, %2]")
|
||||||
.arg(buttonNum, timeoutButtons.size() - 1);
|
.arg(buttonNum,
|
||||||
|
static_cast<int>(timeoutButtons.size()) - 1);
|
||||||
}
|
}
|
||||||
const auto &button = timeoutButtons.at(buttonNum - 1);
|
const auto &button = timeoutButtons.at(buttonNum - 1);
|
||||||
msg = QString("/timeout %1 %2")
|
msg = QString("/timeout %1 %2")
|
||||||
|
@ -690,9 +692,10 @@ void UserInfoPopup::installEvents()
|
||||||
{
|
{
|
||||||
const auto &vector = getSettings()->blacklistedUsers.raw();
|
const auto &vector = getSettings()->blacklistedUsers.raw();
|
||||||
|
|
||||||
for (int i = 0; i < vector.size(); i++)
|
for (int i = 0; i < static_cast<int>(vector.size()); i++)
|
||||||
{
|
{
|
||||||
if (this->userName_ == vector[i].getPattern())
|
if (this->userName_ ==
|
||||||
|
vector[static_cast<size_t>(i)].getPattern())
|
||||||
{
|
{
|
||||||
getSettings()->blacklistedUsers.removeAt(i);
|
getSettings()->blacklistedUsers.removeAt(i);
|
||||||
i--;
|
i--;
|
||||||
|
@ -899,9 +902,9 @@ void UserInfoPopup::updateUserData()
|
||||||
// get ignoreHighlights state
|
// get ignoreHighlights state
|
||||||
bool isIgnoringHighlights = false;
|
bool isIgnoringHighlights = false;
|
||||||
const auto &vector = getSettings()->blacklistedUsers.raw();
|
const auto &vector = getSettings()->blacklistedUsers.raw();
|
||||||
for (int i = 0; i < vector.size(); i++)
|
for (const auto &user : vector)
|
||||||
{
|
{
|
||||||
if (this->userName_ == vector[i].getPattern())
|
if (this->userName_ == user.getPattern())
|
||||||
{
|
{
|
||||||
isIgnoringHighlights = true;
|
isIgnoringHighlights = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -2204,8 +2204,8 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
this->isDoubleClick_ = false;
|
this->isDoubleClick_ = false;
|
||||||
// Was actually not a wanted triple-click
|
// Was actually not a wanted triple-click
|
||||||
if (fabsf(distanceBetweenPoints(this->lastDoubleClickPosition_,
|
if (std::abs(distanceBetweenPoints(this->lastDoubleClickPosition_,
|
||||||
event->screenPos())) > 10.F)
|
event->screenPos())) > 10.F)
|
||||||
{
|
{
|
||||||
this->clickTimer_.stop();
|
this->clickTimer_.stop();
|
||||||
return;
|
return;
|
||||||
|
@ -2215,16 +2215,16 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
this->isLeftMouseDown_ = false;
|
this->isLeftMouseDown_ = false;
|
||||||
|
|
||||||
if (fabsf(distanceBetweenPoints(this->lastLeftPressPosition_,
|
if (std::abs(distanceBetweenPoints(this->lastLeftPressPosition_,
|
||||||
event->screenPos())) > 15.F)
|
event->screenPos())) > 15.F)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Triple-clicking a message selects the whole message
|
// Triple-clicking a message selects the whole message
|
||||||
if (foundElement && this->clickTimer_.isActive() &&
|
if (foundElement && this->clickTimer_.isActive() &&
|
||||||
(fabsf(distanceBetweenPoints(this->lastDoubleClickPosition_,
|
(std::abs(distanceBetweenPoints(this->lastDoubleClickPosition_,
|
||||||
event->screenPos())) < 10.F))
|
event->screenPos())) < 10.F))
|
||||||
{
|
{
|
||||||
this->selectWholeMessage(layout.get(), messageIndex);
|
this->selectWholeMessage(layout.get(), messageIndex);
|
||||||
return;
|
return;
|
||||||
|
@ -2241,8 +2241,8 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
this->isRightMouseDown_ = false;
|
this->isRightMouseDown_ = false;
|
||||||
|
|
||||||
if (fabsf(distanceBetweenPoints(this->lastRightPressPosition_,
|
if (std::abs(distanceBetweenPoints(this->lastRightPressPosition_,
|
||||||
event->screenPos())) > 15.F)
|
event->screenPos())) > 15.F)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,10 +241,8 @@ LimitedQueueSnapshot<MessagePtr> SearchPopup::buildSnapshot()
|
||||||
const LimitedQueueSnapshot<MessagePtr> &snapshot =
|
const LimitedQueueSnapshot<MessagePtr> &snapshot =
|
||||||
sharedView.channel()->getMessageSnapshot();
|
sharedView.channel()->getMessageSnapshot();
|
||||||
|
|
||||||
// TODO: implement iterator on LimitedQueueSnapshot?
|
for (const auto &message : snapshot)
|
||||||
for (auto i = 0; i < snapshot.size(); ++i)
|
|
||||||
{
|
{
|
||||||
const MessagePtr &message = snapshot[i];
|
|
||||||
if (filterSet && !filterSet->filter(message, sharedView.channel()))
|
if (filterSet && !filterSet->filter(message, sharedView.channel()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -19,7 +19,7 @@ QVariant GenericListModel::data(const QModelIndex &index, int /* role */) const
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index.row() >= this->items_.size())
|
if (index.row() >= static_cast<int>(this->items_.size()))
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace {
|
||||||
using namespace chatterino;
|
using namespace chatterino;
|
||||||
|
|
||||||
// 5 minutes
|
// 5 minutes
|
||||||
constexpr const uint64_t THUMBNAIL_MAX_AGE_MS = 5ULL * 60 * 1000;
|
constexpr const qint64 THUMBNAIL_MAX_AGE_MS = 5LL * 60 * 1000;
|
||||||
|
|
||||||
auto formatRoomModeUnclean(
|
auto formatRoomModeUnclean(
|
||||||
const SharedAccessGuard<const TwitchChannel::RoomModes> &modes) -> QString
|
const SharedAccessGuard<const TwitchChannel::RoomModes> &modes) -> QString
|
||||||
|
|
|
@ -180,6 +180,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"flags": "Collapsed|Subscription",
|
"flags": "Collapsed|Subscription",
|
||||||
|
"highlightColor": "#64c466ff",
|
||||||
"id": "8c26e1ab-b50c-4d9d-bc11-3fd57a941d90",
|
"id": "8c26e1ab-b50c-4d9d-bc11-3fd57a941d90",
|
||||||
"localizedName": "",
|
"localizedName": "",
|
||||||
"loginName": "supinic",
|
"loginName": "supinic",
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
"trailingSpace": true,
|
"trailingSpace": true,
|
||||||
"type": "SingleLineTextElement",
|
"type": "SingleLineTextElement",
|
||||||
"words": [
|
"words": [
|
||||||
"a"
|
"b"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -169,6 +169,7 @@
|
||||||
"localizedName": "",
|
"localizedName": "",
|
||||||
"loginName": "nerixyz",
|
"loginName": "nerixyz",
|
||||||
"messageText": "c",
|
"messageText": "c",
|
||||||
|
"replyParent": "474f19ab-a1b0-410a-877a-5b0e2ae8be6d",
|
||||||
"replyThread": {
|
"replyThread": {
|
||||||
"replies": [
|
"replies": [
|
||||||
"474f19ab-a1b0-410a-877a-5b0e2ae8be6d",
|
"474f19ab-a1b0-410a-877a-5b0e2ae8be6d",
|
||||||
|
|
|
@ -256,6 +256,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"flags": "Collapsed|Subscription|SharedMessage",
|
"flags": "Collapsed|Subscription|SharedMessage",
|
||||||
|
"highlightColor": "#64c466ff",
|
||||||
"id": "01cd601f-bc3f-49d5-ab4b-136fa9d6ec22",
|
"id": "01cd601f-bc3f-49d5-ab4b-136fa9d6ec22",
|
||||||
"localizedName": "",
|
"localizedName": "",
|
||||||
"loginName": "lahoooo",
|
"loginName": "lahoooo",
|
||||||
|
|
|
@ -243,6 +243,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"flags": "Collapsed|Subscription",
|
"flags": "Collapsed|Subscription",
|
||||||
|
"highlightColor": "#64c466ff",
|
||||||
"id": "db25007f-7a18-43eb-9379-80131e44d633",
|
"id": "db25007f-7a18-43eb-9379-80131e44d633",
|
||||||
"localizedName": "",
|
"localizedName": "",
|
||||||
"loginName": "ronni",
|
"loginName": "ronni",
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "singletons/Emotes.hpp"
|
#include "singletons/Emotes.hpp"
|
||||||
#include "Test.hpp"
|
#include "Test.hpp"
|
||||||
#include "util/IrcHelpers.hpp"
|
#include "util/IrcHelpers.hpp"
|
||||||
|
#include "util/VectorMessageSink.hpp"
|
||||||
|
|
||||||
#include <IrcConnection>
|
#include <IrcConnection>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -572,19 +573,14 @@ TEST_P(TestIrcMessageHandlerP, Run)
|
||||||
{
|
{
|
||||||
auto channel = makeMockTwitchChannel(u"pajlada"_s, *snapshot);
|
auto channel = makeMockTwitchChannel(u"pajlada"_s, *snapshot);
|
||||||
|
|
||||||
std::vector<MessagePtr> prevMessages;
|
VectorMessageSink sink;
|
||||||
|
|
||||||
for (auto prevInput : snapshot->param("prevMessages").toArray())
|
for (auto prevInput : snapshot->param("prevMessages").toArray())
|
||||||
{
|
{
|
||||||
auto *ircMessage = Communi::IrcMessage::fromData(
|
auto *ircMessage = Communi::IrcMessage::fromData(
|
||||||
prevInput.toString().toUtf8(), nullptr);
|
prevInput.toString().toUtf8(), nullptr);
|
||||||
ASSERT_NE(ircMessage, nullptr);
|
ASSERT_NE(ircMessage, nullptr);
|
||||||
auto builtMessages = IrcMessageHandler::parseMessageWithReply(
|
IrcMessageHandler::parseMessageInto(ircMessage, sink, channel.get());
|
||||||
channel.get(), ircMessage, prevMessages);
|
|
||||||
for (const auto &builtMessage : builtMessages)
|
|
||||||
{
|
|
||||||
prevMessages.emplace_back(builtMessage);
|
|
||||||
}
|
|
||||||
delete ircMessage;
|
delete ircMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -592,13 +588,13 @@ TEST_P(TestIrcMessageHandlerP, Run)
|
||||||
Communi::IrcMessage::fromData(snapshot->inputUtf8(), nullptr);
|
Communi::IrcMessage::fromData(snapshot->inputUtf8(), nullptr);
|
||||||
ASSERT_NE(ircMessage, nullptr);
|
ASSERT_NE(ircMessage, nullptr);
|
||||||
|
|
||||||
auto builtMessages = IrcMessageHandler::parseMessageWithReply(
|
auto firstAddedMsg = sink.messages().size();
|
||||||
channel.get(), ircMessage, prevMessages);
|
IrcMessageHandler::parseMessageInto(ircMessage, sink, channel.get());
|
||||||
|
|
||||||
QJsonArray got;
|
QJsonArray got;
|
||||||
for (const auto &msg : builtMessages)
|
for (auto i = firstAddedMsg; i < sink.messages().size(); i++)
|
||||||
{
|
{
|
||||||
got.append(msg->toJson());
|
got.append(sink.messages()[i]->toJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
delete ircMessage;
|
delete ircMessage;
|
||||||
|
|
Loading…
Reference in a new issue