mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
fix: Mentions of "You" in timeouts will link to your own user now instead of the user "You" (#3922)
* fix: link to the current user in timeouts * fix: `readability-suspicious-call-argument` * docs: add changelog entry * fix: link both users when replacing timeout * Update changelog entry Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
b22c13d589
commit
8ea5b49c52
|
@ -48,6 +48,7 @@
|
||||||
- Bugfix: Always refresh tab when a contained split's channel is set. (#3849)
|
- Bugfix: Always refresh tab when a contained split's channel is set. (#3849)
|
||||||
- Bugfix: Drop trailing whitespace from Twitch system messages. (#3888)
|
- Bugfix: Drop trailing whitespace from Twitch system messages. (#3888)
|
||||||
- Bugfix: Fix crash related to logging IRC channels (#3918)
|
- Bugfix: Fix crash related to logging IRC channels (#3918)
|
||||||
|
- Bugfix: Mentions of "You" in timeouts will link to your own user now instead of the user "You". (#3922)
|
||||||
- Dev: Remove official support for QMake. (#3839, #3883)
|
- Dev: Remove official support for QMake. (#3839, #3883)
|
||||||
- Dev: Rewrite LimitedQueue (#3798)
|
- Dev: Rewrite LimitedQueue (#3798)
|
||||||
- Dev: Overhaul highlight system by moving all checks into a Controller allowing for easier tests. (#3399, #3801, #3835)
|
- Dev: Overhaul highlight system by moving all checks into a Controller allowing for easier tests. (#3399, #3801, #3835)
|
||||||
|
|
|
@ -168,7 +168,8 @@ void Channel::addOrReplaceTimeout(MessagePtr message)
|
||||||
|
|
||||||
int count = s->count + 1;
|
int count = s->count + 1;
|
||||||
|
|
||||||
MessageBuilder replacement(timeoutMessage, message->searchText,
|
MessageBuilder replacement(timeoutMessage, message->timeoutUser,
|
||||||
|
message->loginName, message->searchText,
|
||||||
count);
|
count);
|
||||||
|
|
||||||
replacement->timeoutUser = message->timeoutUser;
|
replacement->timeoutUser = message->timeoutUser;
|
||||||
|
|
|
@ -206,24 +206,45 @@ MessageBuilder::MessageBuilder(SystemMessageTag, const QString &text,
|
||||||
this->message().searchText = text;
|
this->message().searchText = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageBuilder::MessageBuilder(TimeoutMessageTag,
|
MessageBuilder::MessageBuilder(TimeoutMessageTag, const QString &timeoutUser,
|
||||||
|
const QString &sourceUser,
|
||||||
const QString &systemMessageText, int times,
|
const QString &systemMessageText, int times,
|
||||||
const QTime &time)
|
const QTime &time)
|
||||||
: MessageBuilder()
|
: MessageBuilder()
|
||||||
{
|
{
|
||||||
QString username = systemMessageText.split(" ").at(0);
|
QString usernameText = systemMessageText.split(" ").at(0);
|
||||||
QString remainder = systemMessageText.mid(username.length() + 1);
|
QString remainder = systemMessageText.mid(usernameText.length() + 1);
|
||||||
|
bool timeoutUserIsFirst =
|
||||||
QString text;
|
usernameText == "You" || timeoutUser == usernameText;
|
||||||
|
QString messageText;
|
||||||
|
|
||||||
this->emplace<TimestampElement>(time);
|
this->emplace<TimestampElement>(time);
|
||||||
this->emplaceSystemTextAndUpdate(username, text)
|
this->emplaceSystemTextAndUpdate(usernameText, messageText)
|
||||||
->setLink({Link::UserInfo, username});
|
->setLink(
|
||||||
this->emplaceSystemTextAndUpdate(
|
{Link::UserInfo, timeoutUserIsFirst ? timeoutUser : sourceUser});
|
||||||
QString("%1 (%2 times)").arg(remainder.trimmed()).arg(times), text);
|
|
||||||
|
|
||||||
this->message().messageText = text;
|
if (!sourceUser.isEmpty())
|
||||||
this->message().searchText = text;
|
{
|
||||||
|
// the second username in the message
|
||||||
|
const auto &targetUsername =
|
||||||
|
timeoutUserIsFirst ? sourceUser : timeoutUser;
|
||||||
|
int userPos = remainder.indexOf(targetUsername);
|
||||||
|
|
||||||
|
QString mid = remainder.mid(0, userPos - 1);
|
||||||
|
QString username = remainder.mid(userPos, targetUsername.length());
|
||||||
|
remainder = remainder.mid(userPos + targetUsername.length() + 1);
|
||||||
|
|
||||||
|
this->emplaceSystemTextAndUpdate(mid, messageText);
|
||||||
|
this->emplaceSystemTextAndUpdate(username, messageText)
|
||||||
|
->setLink({Link::UserInfo, username});
|
||||||
|
}
|
||||||
|
|
||||||
|
this->emplaceSystemTextAndUpdate(
|
||||||
|
QString("%1 (%2 times)").arg(remainder.trimmed()).arg(times),
|
||||||
|
messageText);
|
||||||
|
|
||||||
|
this->message().messageText = messageText;
|
||||||
|
this->message().searchText = messageText;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageBuilder::MessageBuilder(TimeoutMessageTag, const QString &username,
|
MessageBuilder::MessageBuilder(TimeoutMessageTag, const QString &username,
|
||||||
|
@ -284,13 +305,16 @@ MessageBuilder::MessageBuilder(const BanAction &action, uint32_t count)
|
||||||
this->message().flags.set(MessageFlag::System);
|
this->message().flags.set(MessageFlag::System);
|
||||||
this->message().flags.set(MessageFlag::Timeout);
|
this->message().flags.set(MessageFlag::Timeout);
|
||||||
this->message().timeoutUser = action.target.login;
|
this->message().timeoutUser = action.target.login;
|
||||||
|
this->message().loginName = action.source.login;
|
||||||
this->message().count = count;
|
this->message().count = count;
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
|
|
||||||
if (action.target.id == current->getUserId())
|
if (action.target.id == current->getUserId())
|
||||||
{
|
{
|
||||||
this->emplaceSystemTextAndUpdate("You were", text);
|
this->emplaceSystemTextAndUpdate("You", text)
|
||||||
|
->setLink({Link::UserInfo, current->getUserName()});
|
||||||
|
this->emplaceSystemTextAndUpdate("were", text);
|
||||||
if (action.isBan())
|
if (action.isBan())
|
||||||
{
|
{
|
||||||
this->emplaceSystemTextAndUpdate("banned", text);
|
this->emplaceSystemTextAndUpdate("banned", text);
|
||||||
|
|
|
@ -44,7 +44,8 @@ public:
|
||||||
MessageBuilder();
|
MessageBuilder();
|
||||||
MessageBuilder(SystemMessageTag, const QString &text,
|
MessageBuilder(SystemMessageTag, const QString &text,
|
||||||
const QTime &time = QTime::currentTime());
|
const QTime &time = QTime::currentTime());
|
||||||
MessageBuilder(TimeoutMessageTag, const QString &systemMessageText,
|
MessageBuilder(TimeoutMessageTag, const QString &timeoutUser,
|
||||||
|
const QString &sourceUser, const QString &systemMessageText,
|
||||||
int times, const QTime &time = QTime::currentTime());
|
int times, const QTime &time = QTime::currentTime());
|
||||||
MessageBuilder(TimeoutMessageTag, const QString &username,
|
MessageBuilder(TimeoutMessageTag, const QString &username,
|
||||||
const QString &durationInSeconds, bool multipleTimes,
|
const QString &durationInSeconds, bool multipleTimes,
|
||||||
|
|
Loading…
Reference in a new issue