mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Compare commits
1 commit
6c718d58bd
...
69c87652ab
Author | SHA1 | Date | |
---|---|---|---|
69c87652ab |
|
@ -110,7 +110,7 @@
|
||||||
- Dev: Emojis now use flags instead of a set of strings for capabilities. (#5616)
|
- Dev: Emojis now use flags instead of a set of strings for capabilities. (#5616)
|
||||||
- Dev: Move plugins to Sol2. (#5622)
|
- Dev: Move plugins to Sol2. (#5622)
|
||||||
- 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)
|
||||||
- Dev: Refactored IRC message building. (#5663)
|
- Dev: Refactored IRC message building. (#5663)
|
||||||
|
|
||||||
## 2.5.1
|
## 2.5.1
|
||||||
|
|
|
@ -2382,11 +2382,6 @@ void MessageBuilder::parseThread(const QString &messageContent,
|
||||||
this->message().replyParent = parent;
|
this->message().replyParent = parent;
|
||||||
thread->addToThread(std::weak_ptr{this->message_});
|
thread->addToThread(std::weak_ptr{this->message_});
|
||||||
|
|
||||||
if (thread->subscribed())
|
|
||||||
{
|
|
||||||
this->message().flags.set(MessageFlag::SubscribedThread);
|
|
||||||
}
|
|
||||||
|
|
||||||
// enable reply flag
|
// enable reply flag
|
||||||
this->message().flags.set(MessageFlag::ReplyMessage);
|
this->message().flags.set(MessageFlag::ReplyMessage);
|
||||||
|
|
||||||
|
|
|
@ -123,34 +123,47 @@ int stripLeadingReplyMention(const QVariantMap &tags, QString &content)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkThreadSubscription(const QVariantMap &tags,
|
[[nodiscard]] bool shouldHighlightReplyThread(
|
||||||
const QString &senderLogin,
|
const QVariantMap &tags, const QString &senderLogin,
|
||||||
std::shared_ptr<MessageThread> &thread)
|
std::shared_ptr<MessageThread> &thread, bool isNew)
|
||||||
{
|
|
||||||
if (thread->subscribed() || thread->unsubscribed())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getSettings()->autoSubToParticipatedThreads)
|
|
||||||
{
|
{
|
||||||
const auto ¤tLogin =
|
const auto ¤tLogin =
|
||||||
getApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
getApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
||||||
|
|
||||||
if (senderLogin == currentLogin)
|
if (thread->subscribed())
|
||||||
{
|
{
|
||||||
thread->markSubscribed();
|
return true;
|
||||||
}
|
}
|
||||||
else if (const auto it = tags.find("reply-parent-user-login");
|
|
||||||
|
if (thread->unsubscribed())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getSettings()->autoSubToParticipatedThreads)
|
||||||
|
{
|
||||||
|
if (isNew)
|
||||||
|
{
|
||||||
|
if (const auto it = tags.find("reply-parent-user-login");
|
||||||
it != tags.end())
|
it != tags.end())
|
||||||
{
|
{
|
||||||
auto name = it.value().toString();
|
auto name = it.value().toString();
|
||||||
if (name == currentLogin)
|
if (name == currentLogin)
|
||||||
{
|
{
|
||||||
thread->markSubscribed();
|
thread->markSubscribed();
|
||||||
|
return true; // already marked as participated
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (senderLogin == currentLogin)
|
||||||
|
{
|
||||||
|
thread->markSubscribed();
|
||||||
|
// don't set the highlight here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelPtr channelOrEmptyByTarget(const QString &target,
|
ChannelPtr channelOrEmptyByTarget(const QString &target,
|
||||||
|
@ -230,6 +243,7 @@ QMap<QString, QString> parseBadges(const QString &badgesString)
|
||||||
struct ReplyContext {
|
struct ReplyContext {
|
||||||
std::shared_ptr<MessageThread> thread;
|
std::shared_ptr<MessageThread> thread;
|
||||||
MessagePtr parent;
|
MessagePtr parent;
|
||||||
|
bool highlight = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] ReplyContext getReplyContext(
|
[[nodiscard]] ReplyContext getReplyContext(
|
||||||
|
@ -251,7 +265,8 @@ struct ReplyContext {
|
||||||
if (owned)
|
if (owned)
|
||||||
{
|
{
|
||||||
// Thread already exists (has a reply)
|
// Thread already exists (has a reply)
|
||||||
checkThreadSubscription(tags, message->nick(), owned);
|
ctx.highlight = shouldHighlightReplyThread(
|
||||||
|
tags, message->nick(), owned, false);
|
||||||
ctx.thread = owned;
|
ctx.thread = owned;
|
||||||
rootThread = owned;
|
rootThread = owned;
|
||||||
}
|
}
|
||||||
|
@ -286,7 +301,8 @@ struct ReplyContext {
|
||||||
{
|
{
|
||||||
std::shared_ptr<MessageThread> newThread =
|
std::shared_ptr<MessageThread> newThread =
|
||||||
std::make_shared<MessageThread>(foundMessage);
|
std::make_shared<MessageThread>(foundMessage);
|
||||||
checkThreadSubscription(tags, message->nick(), newThread);
|
ctx.highlight = shouldHighlightReplyThread(
|
||||||
|
tags, message->nick(), newThread, true);
|
||||||
|
|
||||||
ctx.thread = newThread;
|
ctx.thread = newThread;
|
||||||
rootThread = newThread;
|
rootThread = newThread;
|
||||||
|
@ -708,6 +724,10 @@ std::vector<MessagePtr> IrcMessageHandler::parseMessageWithReply(
|
||||||
|
|
||||||
if (built)
|
if (built)
|
||||||
{
|
{
|
||||||
|
if (replyCtx.highlight)
|
||||||
|
{
|
||||||
|
built->flags.set(MessageFlag::SubscribedThread);
|
||||||
|
}
|
||||||
builtMessages.emplace_back(built);
|
builtMessages.emplace_back(built);
|
||||||
MessageBuilder::triggerHighlights(channel, alert);
|
MessageBuilder::triggerHighlights(channel, alert);
|
||||||
}
|
}
|
||||||
|
@ -1532,7 +1552,8 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
|
||||||
{
|
{
|
||||||
// Thread already exists (has a reply)
|
// Thread already exists (has a reply)
|
||||||
auto thread = threadIt->second.lock();
|
auto thread = threadIt->second.lock();
|
||||||
checkThreadSubscription(tags, message->nick(), thread);
|
replyCtx.highlight = shouldHighlightReplyThread(
|
||||||
|
tags, message->nick(), thread, false);
|
||||||
replyCtx.thread = thread;
|
replyCtx.thread = thread;
|
||||||
rootThread = thread;
|
rootThread = thread;
|
||||||
}
|
}
|
||||||
|
@ -1544,7 +1565,8 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
|
||||||
{
|
{
|
||||||
// Found root reply message
|
// Found root reply message
|
||||||
auto newThread = std::make_shared<MessageThread>(root);
|
auto newThread = std::make_shared<MessageThread>(root);
|
||||||
checkThreadSubscription(tags, message->nick(), newThread);
|
replyCtx.highlight = shouldHighlightReplyThread(
|
||||||
|
tags, message->nick(), newThread, true);
|
||||||
|
|
||||||
replyCtx.thread = newThread;
|
replyCtx.thread = newThread;
|
||||||
rootThread = newThread;
|
rootThread = newThread;
|
||||||
|
@ -1599,6 +1621,10 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
|
||||||
msg->flags.set(MessageFlag::Subscription);
|
msg->flags.set(MessageFlag::Subscription);
|
||||||
msg->flags.unset(MessageFlag::Highlighted);
|
msg->flags.unset(MessageFlag::Highlighted);
|
||||||
}
|
}
|
||||||
|
if (replyCtx.highlight)
|
||||||
|
{
|
||||||
|
msg->flags.set(MessageFlag::SubscribedThread);
|
||||||
|
}
|
||||||
|
|
||||||
IrcMessageHandler::setSimilarityFlags(msg, chan);
|
IrcMessageHandler::setSimilarityFlags(msg, chan);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue