Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split log line generation from message search text #4742

Merged
merged 4 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(':');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'colonIndex' of type 'qsizetype' (aka 'long long') can be declared 'const' [misc-const-correctness]

Suggested change
qsizetype colonIndex = messageText.indexOf(':');
qsizetype const colonIndex = messageText.indexOf(':');

if (colonIndex != -1)
{
QString rootMessageChatter =
message->replyThread->root()->loginName;
messageSearchText.insert(colonIndex + 1, " @" + rootMessageChatter);
messageText.insert(colonIndex + 1, " @" + rootMessageChatter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'long long' to signed type 'int' is implementation-defined [bugprone-narrowing-conversions]

            messageText.insert(colonIndex + 1, " @" + rootMessageChatter);
                               ^

}
}
str.append(messageSearchText);
str.append(messageText);
str.append(endline);

this->appendLine(str);
Expand Down