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