mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
refactor: remove unused ReplyContext.highlight (#5669)
This commit is contained in:
parent
45d2c292d0
commit
2ec8fa8723
1 changed files with 20 additions and 46 deletions
|
@ -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 ¤tLogin =
|
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 ¤tLogin =
|
||||||
{
|
getApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
||||||
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)
|
if (senderLogin == currentLogin)
|
||||||
{
|
{
|
||||||
thread->markSubscribed();
|
thread->markSubscribed();
|
||||||
// don't set the highlight here
|
}
|
||||||
|
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 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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue