From e13df1f602fd4027495fdbe2cc959c7896a0196a Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Sat, 5 Aug 2023 15:09:56 +0200 Subject: [PATCH] Split log line generation from message search text (#4742) * 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 --- CHANGELOG.md | 2 +- src/singletons/helper/LoggingChannel.cpp | 27 ++++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 445a93d2a..cd27db1aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ` commands to shoutout specified user. (#4638) - Minor: Improved editing hotkeys. (#4628) diff --git a/src/singletons/helper/LoggingChannel.cpp b/src/singletons/helper/LoggingChannel.cpp index 9f10f87c3..b47aec19d 100644 --- a/src/singletons/helper/LoggingChannel.cpp +++ b/src/singletons/helper/LoggingChannel.cpp @@ -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);