Skip to content

Commit

Permalink
Split log line generation from message search text (Chatterino#4742)
Browse files Browse the repository at this point in the history
* Split log line generation from message search text

* changelog

* remove empty space at the beginning of usernames

* Move changelog entry

---------

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
  • Loading branch information
2 people authored and Nerixyz committed Aug 19, 2023
1 parent cec365f commit 73407bf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- Minor: Message input is now focused when clicking on emotes. (#4719)
- Minor: Changed viewer list to chatter list to more match Twitch's terminology. (#4732)
- Minor: Nicknames are now taken into consideration when searching for messages. (#4663)
- Minor: Nicknames are now taken into consideration when searching for messages. (#4663, #4742)
- Minor: Add an icon showing when streamer mode is enabled (#4410, #4690)
- Minor: Added `/shoutout <username>` commands to shoutout specified user. (#4638)
- Minor: Improved editing hotkeys. (#4628)
Expand Down
27 changes: 23 additions & 4 deletions src/singletons/helper/LoggingChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,39 @@ void LoggingChannel::addMessage(MessagePtr message)
str.append(now.toString("HH:mm:ss"));
str.append("] ");

QString messageSearchText = message->searchText;
QString messageText;
if (message->loginName.isEmpty())
{
// This accounts for any messages not explicitly sent by a user, like
// system messages, parts of announcements, subs etc.
messageText = message->messageText;
}
else
{
if (message->localizedName.isEmpty())
{
messageText = message->loginName + ": " + message->messageText;
}
else
{
messageText = message->localizedName + " " + message->loginName +
": " + message->messageText;
}
}

if ((message->flags.has(MessageFlag::ReplyMessage) &&
getSettings()->stripReplyMention) &&
!getSettings()->hideReplyContext)
{
qsizetype colonIndex = messageSearchText.indexOf(':');
qsizetype colonIndex = messageText.indexOf(':');
if (colonIndex != -1)
{
QString rootMessageChatter =
message->replyThread->root()->loginName;
messageSearchText.insert(colonIndex + 1, " @" + rootMessageChatter);
messageText.insert(colonIndex + 1, " @" + rootMessageChatter);
}
}
str.append(messageSearchText);
str.append(messageText);
str.append(endline);

this->appendLine(str);
Expand Down

0 comments on commit 73407bf

Please sign in to comment.