Compare commits

...

3 commits

Author SHA1 Message Date
hemirt fb60b208b1
Merge e5e5a79645 into 2ec8fa8723 2024-10-22 08:04:52 +00:00
pajlada 2ec8fa8723
refactor: remove unused ReplyContext.highlight (#5669) 2024-10-21 19:22:23 +02:00
pajlada 45d2c292d0
fix: subscribed threads not being marked as subscribed (#5668) 2024-10-21 13:19:08 +02:00
3 changed files with 26 additions and 47 deletions

View file

@ -111,7 +111,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) - Dev: Decoupled reply parsing from `MessageBuilder`. (#5660, #5668)
- Dev: Refactored IRC message building. (#5663) - Dev: Refactored IRC message building. (#5663)
## 2.5.1 ## 2.5.1

View file

@ -2382,6 +2382,11 @@ 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);

View file

@ -123,47 +123,34 @@ int stripLeadingReplyMention(const QVariantMap &tags, QString &content)
return 0; return 0;
} }
[[nodiscard]] bool shouldHighlightReplyThread( void checkThreadSubscription(const QVariantMap &tags,
const QVariantMap &tags, const QString &senderLogin, const QString &senderLogin,
std::shared_ptr<MessageThread> &thread, bool isNew) std::shared_ptr<MessageThread> &thread)
{ {
const auto &currentLogin = if (thread->subscribed() || thread->unsubscribed())
getApp()->getAccounts()->twitch.getCurrent()->getUserName();
if (thread->subscribed())
{ {
return true; return;
}
if (thread->unsubscribed())
{
return false;
} }
if (getSettings()->autoSubToParticipatedThreads) if (getSettings()->autoSubToParticipatedThreads)
{ {
if (isNew) const auto &currentLogin =
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()) 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,
@ -243,7 +230,6 @@ 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(
@ -265,8 +251,7 @@ struct ReplyContext {
if (owned) if (owned)
{ {
// Thread already exists (has a reply) // Thread already exists (has a reply)
ctx.highlight = shouldHighlightReplyThread( checkThreadSubscription(tags, message->nick(), owned);
tags, message->nick(), owned, false);
ctx.thread = owned; ctx.thread = owned;
rootThread = owned; rootThread = owned;
} }
@ -301,8 +286,7 @@ struct ReplyContext {
{ {
std::shared_ptr<MessageThread> newThread = std::shared_ptr<MessageThread> newThread =
std::make_shared<MessageThread>(foundMessage); std::make_shared<MessageThread>(foundMessage);
ctx.highlight = shouldHighlightReplyThread( checkThreadSubscription(tags, message->nick(), newThread);
tags, message->nick(), newThread, true);
ctx.thread = newThread; ctx.thread = newThread;
rootThread = newThread; rootThread = newThread;
@ -724,10 +708,6 @@ 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);
} }
@ -1552,8 +1532,7 @@ 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();
replyCtx.highlight = shouldHighlightReplyThread( checkThreadSubscription(tags, message->nick(), thread);
tags, message->nick(), thread, false);
replyCtx.thread = thread; replyCtx.thread = thread;
rootThread = thread; rootThread = thread;
} }
@ -1565,8 +1544,7 @@ 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);
replyCtx.highlight = shouldHighlightReplyThread( checkThreadSubscription(tags, message->nick(), newThread);
tags, message->nick(), newThread, true);
replyCtx.thread = newThread; replyCtx.thread = newThread;
rootThread = newThread; rootThread = newThread;
@ -1621,10 +1599,6 @@ 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);