mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Fixed restricted users' usernames not being clickable (#5405)
This commit is contained in:
parent
65bfec963b
commit
2a46ee708e
|
@ -11,6 +11,7 @@
|
||||||
- Minor: Added the ability to duplicate tabs. (#5277)
|
- Minor: Added the ability to duplicate tabs. (#5277)
|
||||||
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426)
|
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426)
|
||||||
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
|
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
|
||||||
|
- Bugfix: Fixed restricted users usernames not being clickable. (#5405)
|
||||||
- Bugfix: Fixed a crash that could occur when logging was enabled in IRC servers that were removed. (#5419)
|
- Bugfix: Fixed a crash that could occur when logging was enabled in IRC servers that were removed. (#5419)
|
||||||
- Dev: Update Windows build from Qt 6.5.0 to Qt 6.7.1. (#5420)
|
- Dev: Update Windows build from Qt 6.5.0 to Qt 6.7.1. (#5420)
|
||||||
- Dev: Update vcpkg build Qt from 6.5.0 to 6.7.0, boost from 1.83.0 to 1.85.0, openssl from 3.1.3 to 3.3.0. (#5422)
|
- Dev: Update vcpkg build Qt from 6.5.0 to 6.7.0, boost from 1.83.0 to 1.85.0, openssl from 3.1.3 to 3.3.0. (#5422)
|
||||||
|
|
|
@ -763,7 +763,7 @@ void MessageBuilder::addTextOrEmoji(const QString &string_)
|
||||||
auto &&textColor = this->textColor_;
|
auto &&textColor = this->textColor_;
|
||||||
if (string.startsWith('@'))
|
if (string.startsWith('@'))
|
||||||
{
|
{
|
||||||
this->emplace<MentionElement>(string, textColor, textColor);
|
this->emplace<MentionElement>(string, "", textColor, textColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -703,11 +703,14 @@ Link LinkElement::getLink() const
|
||||||
return {Link::Url, this->linkInfo_.url()};
|
return {Link::Url, this->linkInfo_.url()};
|
||||||
}
|
}
|
||||||
|
|
||||||
MentionElement::MentionElement(const QString &name, MessageColor fallbackColor_,
|
MentionElement::MentionElement(const QString &displayName, QString loginName_,
|
||||||
|
MessageColor fallbackColor_,
|
||||||
MessageColor userColor_)
|
MessageColor userColor_)
|
||||||
: TextElement(name, {MessageElementFlag::Text, MessageElementFlag::Mention})
|
: TextElement(displayName,
|
||||||
|
{MessageElementFlag::Text, MessageElementFlag::Mention})
|
||||||
, fallbackColor(fallbackColor_)
|
, fallbackColor(fallbackColor_)
|
||||||
, userColor(userColor_)
|
, userColor(userColor_)
|
||||||
|
, userLoginName(std::move(loginName_))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,6 +738,26 @@ void MentionElement::addToContainer(MessageLayoutContainer &container,
|
||||||
TextElement::addToContainer(container, flags);
|
TextElement::addToContainer(container, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageElement *MentionElement::setLink(const Link &link)
|
||||||
|
{
|
||||||
|
assert(false && "MentionElement::setLink should not be called. Pass "
|
||||||
|
"through a valid login name in the constructor and it will "
|
||||||
|
"automatically be a UserInfo link");
|
||||||
|
|
||||||
|
return TextElement::setLink(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
Link MentionElement::getLink() const
|
||||||
|
{
|
||||||
|
if (this->userLoginName.isEmpty())
|
||||||
|
{
|
||||||
|
// Some rare mention elements don't have the knowledge of the login name
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {Link::UserInfo, this->userLoginName};
|
||||||
|
}
|
||||||
|
|
||||||
// TIMESTAMP
|
// TIMESTAMP
|
||||||
TimestampElement::TimestampElement(QTime time)
|
TimestampElement::TimestampElement(QTime time)
|
||||||
: MessageElement(MessageElementFlag::Timestamp)
|
: MessageElement(MessageElementFlag::Timestamp)
|
||||||
|
|
|
@ -169,7 +169,7 @@ public:
|
||||||
MessageElement(MessageElement &&) = delete;
|
MessageElement(MessageElement &&) = delete;
|
||||||
MessageElement &operator=(MessageElement &&) = delete;
|
MessageElement &operator=(MessageElement &&) = delete;
|
||||||
|
|
||||||
MessageElement *setLink(const Link &link);
|
virtual MessageElement *setLink(const Link &link);
|
||||||
MessageElement *setTooltip(const QString &tooltip);
|
MessageElement *setTooltip(const QString &tooltip);
|
||||||
|
|
||||||
MessageElement *setTrailingSpace(bool value);
|
MessageElement *setTrailingSpace(bool value);
|
||||||
|
@ -314,8 +314,8 @@ private:
|
||||||
class MentionElement : public TextElement
|
class MentionElement : public TextElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MentionElement(const QString &name, MessageColor fallbackColor_,
|
MentionElement(const QString &displayName, QString loginName_,
|
||||||
MessageColor userColor_);
|
MessageColor fallbackColor_, MessageColor userColor_);
|
||||||
~MentionElement() override = default;
|
~MentionElement() override = default;
|
||||||
MentionElement(const MentionElement &) = delete;
|
MentionElement(const MentionElement &) = delete;
|
||||||
MentionElement(MentionElement &&) = delete;
|
MentionElement(MentionElement &&) = delete;
|
||||||
|
@ -325,6 +325,9 @@ public:
|
||||||
void addToContainer(MessageLayoutContainer &container,
|
void addToContainer(MessageLayoutContainer &container,
|
||||||
MessageElementFlags flags) override;
|
MessageElementFlags flags) override;
|
||||||
|
|
||||||
|
MessageElement *setLink(const Link &link) override;
|
||||||
|
Link getLink() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* The color of the element in case the "Colorize @usernames" is disabled
|
* The color of the element in case the "Colorize @usernames" is disabled
|
||||||
|
@ -335,6 +338,8 @@ private:
|
||||||
* The color of the element in case the "Colorize @usernames" is enabled
|
* The color of the element in case the "Colorize @usernames" is enabled
|
||||||
**/
|
**/
|
||||||
MessageColor userColor;
|
MessageColor userColor;
|
||||||
|
|
||||||
|
QString userLoginName;
|
||||||
};
|
};
|
||||||
|
|
||||||
// contains emote data and will pick the emote based on :
|
// contains emote data and will pick the emote based on :
|
||||||
|
|
|
@ -770,9 +770,8 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_)
|
||||||
|
|
||||||
auto prefixedUsername = '@' + username;
|
auto prefixedUsername = '@' + username;
|
||||||
auto remainder = string.remove(prefixedUsername);
|
auto remainder = string.remove(prefixedUsername);
|
||||||
this->emplace<MentionElement>(prefixedUsername, originalTextColor,
|
this->emplace<MentionElement>(prefixedUsername, username,
|
||||||
textColor)
|
originalTextColor, textColor)
|
||||||
->setLink({Link::UserInfo, username})
|
|
||||||
->setTrailingSpace(remainder.isEmpty());
|
->setTrailingSpace(remainder.isEmpty());
|
||||||
|
|
||||||
if (!remainder.isEmpty())
|
if (!remainder.isEmpty())
|
||||||
|
@ -802,9 +801,8 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto remainder = string.remove(username);
|
auto remainder = string.remove(username);
|
||||||
this->emplace<MentionElement>(username, originalTextColor,
|
this->emplace<MentionElement>(username, username, originalTextColor,
|
||||||
textColor)
|
textColor)
|
||||||
->setLink({Link::UserInfo, username})
|
|
||||||
->setTrailingSpace(remainder.isEmpty());
|
->setTrailingSpace(remainder.isEmpty());
|
||||||
|
|
||||||
if (!remainder.isEmpty())
|
if (!remainder.isEmpty())
|
||||||
|
@ -1821,8 +1819,10 @@ void TwitchMessageBuilder::listOfUsersSystemMessage(QString prefix,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
builder->emplace<MentionElement>(username, MessageColor::System, color)
|
// TODO: Ensure we make use of display name / username(login name) correctly here
|
||||||
->setLink({Link::UserInfo, username})
|
builder
|
||||||
|
->emplace<MentionElement>(username, username, MessageColor::System,
|
||||||
|
color)
|
||||||
->setTrailingSpace(false);
|
->setTrailingSpace(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1867,9 +1867,8 @@ void TwitchMessageBuilder::listOfUsersSystemMessage(
|
||||||
}
|
}
|
||||||
|
|
||||||
builder
|
builder
|
||||||
->emplace<MentionElement>(user.userName, MessageColor::System,
|
->emplace<MentionElement>(user.userName, user.userLogin,
|
||||||
color)
|
MessageColor::System, color)
|
||||||
->setLink({Link::UserInfo, user.userLogin})
|
|
||||||
->setTrailingSpace(false);
|
->setTrailingSpace(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1938,8 +1937,8 @@ MessagePtr TwitchMessageBuilder::makeAutomodInfoMessage(
|
||||||
builder.emplace<BadgeElement>(makeAutoModBadge(),
|
builder.emplace<BadgeElement>(makeAutoModBadge(),
|
||||||
MessageElementFlag::BadgeChannelAuthority);
|
MessageElementFlag::BadgeChannelAuthority);
|
||||||
// AutoMod "username"
|
// AutoMod "username"
|
||||||
builder.emplace<MentionElement>("AutoMod:", AUTOMOD_USER_COLOR,
|
builder.emplace<TextElement>("AutoMod:", MessageElementFlag::Text,
|
||||||
AUTOMOD_USER_COLOR);
|
AUTOMOD_USER_COLOR, FontStyle::ChatMediumBold);
|
||||||
switch (action.type)
|
switch (action.type)
|
||||||
{
|
{
|
||||||
case AutomodInfoAction::OnHold: {
|
case AutomodInfoAction::OnHold: {
|
||||||
|
@ -1993,8 +1992,9 @@ std::pair<MessagePtr, MessagePtr> TwitchMessageBuilder::makeAutomodMessage(
|
||||||
builder.emplace<BadgeElement>(makeAutoModBadge(),
|
builder.emplace<BadgeElement>(makeAutoModBadge(),
|
||||||
MessageElementFlag::BadgeChannelAuthority);
|
MessageElementFlag::BadgeChannelAuthority);
|
||||||
// AutoMod "username"
|
// AutoMod "username"
|
||||||
builder2.emplace<MentionElement>("AutoMod:", AUTOMOD_USER_COLOR,
|
builder2.emplace<TextElement>("AutoMod:", MessageElementFlag::Text,
|
||||||
AUTOMOD_USER_COLOR);
|
AUTOMOD_USER_COLOR,
|
||||||
|
FontStyle::ChatMediumBold);
|
||||||
// AutoMod header message
|
// AutoMod header message
|
||||||
builder.emplace<TextElement>(
|
builder.emplace<TextElement>(
|
||||||
("Held a message for reason: " + action.reason +
|
("Held a message for reason: " + action.reason +
|
||||||
|
@ -2041,10 +2041,9 @@ std::pair<MessagePtr, MessagePtr> TwitchMessageBuilder::makeAutomodMessage(
|
||||||
builder2.message().flags.set(MessageFlag::AutoModOffendingMessage);
|
builder2.message().flags.set(MessageFlag::AutoModOffendingMessage);
|
||||||
|
|
||||||
// sender username
|
// sender username
|
||||||
builder2
|
builder2.emplace<MentionElement>(action.target.displayName + ":",
|
||||||
.emplace<MentionElement>(action.target.displayName + ":",
|
action.target.login, MessageColor::Text,
|
||||||
MessageColor::Text, action.target.color)
|
action.target.color);
|
||||||
->setLink({Link::UserInfo, action.target.login});
|
|
||||||
// sender's message caught by AutoMod
|
// sender's message caught by AutoMod
|
||||||
builder2.emplace<TextElement>(action.message, MessageElementFlag::Text,
|
builder2.emplace<TextElement>(action.message, MessageElementFlag::Text,
|
||||||
MessageColor::Text);
|
MessageColor::Text);
|
||||||
|
@ -2239,9 +2238,9 @@ std::pair<MessagePtr, MessagePtr> TwitchMessageBuilder::makeLowTrustUserMessage(
|
||||||
appendBadges(&builder2, action.senderBadges, {}, twitchChannel);
|
appendBadges(&builder2, action.senderBadges, {}, twitchChannel);
|
||||||
|
|
||||||
// sender username
|
// sender username
|
||||||
builder2.emplace<MentionElement>(action.suspiciousUserDisplayName + ":",
|
builder2.emplace<MentionElement>(
|
||||||
MessageColor::Text,
|
action.suspiciousUserDisplayName + ":", action.suspiciousUserLogin,
|
||||||
action.suspiciousUserColor);
|
MessageColor::Text, action.suspiciousUserColor);
|
||||||
|
|
||||||
// sender's message caught by AutoMod
|
// sender's message caught by AutoMod
|
||||||
for (const auto &fragment : action.fragments)
|
for (const auto &fragment : action.fragments)
|
||||||
|
|
Loading…
Reference in a new issue