refactor: move zero width replacement to a function (#5594)

This commit is contained in:
nerix
2024-09-28 14:49:26 +02:00
committed by GitHub
parent e149be3820
commit d0bcf35fdc
7 changed files with 89 additions and 46 deletions
+2 -15
View File
@@ -1,22 +1,13 @@
#include "providers/recentmessages/Impl.hpp"
#include "common/Env.hpp"
#include "common/QLogging.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/twitch/IrcMessageHandler.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "util/FormatTime.hpp"
#include "util/Helpers.hpp"
#include <QJsonArray>
#include <QUrlQuery>
namespace {
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
const auto &LOG = chatterinoRecentMessages;
} // namespace
namespace chatterino::recentmessages::detail {
// Parse the IRC messages returned in JSON form into Communi messages
@@ -33,11 +24,7 @@ std::vector<Communi::IrcMessage *> parseRecentMessages(
for (const auto &jsonMessage : jsonMessages)
{
auto content = jsonMessage.toString();
// For explanation of why this exists, see src/providers/twitch/TwitchChannel.hpp,
// where these constants are defined
content.replace(COMBINED_FIXER, ZERO_WIDTH_JOINER);
auto content = unescapeZeroWidthJoiner(jsonMessage.toString());
auto *message =
Communi::IrcMessage::fromData(content.toUtf8(), nullptr);