feat: Use streamer profile picture for shared chat badge (#5760)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com> Co-authored-by: Nerixyz <nerixdev@outlook.de>
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## Unversioned
|
## Unversioned
|
||||||
|
|
||||||
|
- Minor: Shared chat messages now use the source channel's profile picture to denote it's a shared chat message. (#5760)
|
||||||
- Minor: Moved the "Delete message" menu option into a "Moderate" sub-menu. (#6100)
|
- Minor: Moved the "Delete message" menu option into a "Moderate" sub-menu. (#6100)
|
||||||
- Bugfix: Fixed the channel name input not being focused when opening the select-channel dialog. (#6096)
|
- Bugfix: Fixed the channel name input not being focused when opening the select-channel dialog. (#6096)
|
||||||
- Bugfix: Fixed inputs in dialogs not having a border around and padding in them. (#6098)
|
- Bugfix: Fixed inputs in dialogs not having a border around and padding in them. (#6098)
|
||||||
|
|||||||
@@ -385,8 +385,36 @@ EmotePtr makeAutoModBadge()
|
|||||||
Url{"https://dashboard.twitch.tv/settings/moderation/automod"}});
|
Url{"https://dashboard.twitch.tv/settings/moderation/automod"}});
|
||||||
}
|
}
|
||||||
|
|
||||||
EmotePtr makeSharedChatBadge(const QString &sourceName)
|
EmotePtr makeSharedChatBadge(const QString &sourceName,
|
||||||
|
const QString &sourceProfileURL,
|
||||||
|
const QString &sourceLogin)
|
||||||
{
|
{
|
||||||
|
if (!sourceProfileURL.isEmpty())
|
||||||
|
{
|
||||||
|
QString modifiedUrl = sourceProfileURL;
|
||||||
|
modifiedUrl.replace("300x300", "28x28");
|
||||||
|
|
||||||
|
auto badgeLink = [&] {
|
||||||
|
if (sourceLogin.isEmpty())
|
||||||
|
{
|
||||||
|
return Url{"https://link.twitch.tv/SharedChatViewer"};
|
||||||
|
}
|
||||||
|
|
||||||
|
return Url{u"https://twitch.tv/%1"_s.arg(sourceLogin)};
|
||||||
|
}();
|
||||||
|
|
||||||
|
return std::make_shared<Emote>(Emote{
|
||||||
|
.name = EmoteName{},
|
||||||
|
.images = ImageSet{Image::fromUrl(
|
||||||
|
Url{modifiedUrl},
|
||||||
|
18.F / 28.F)}, // get as close to 18x18 as possible
|
||||||
|
.tooltip =
|
||||||
|
Tooltip{"Shared Message" +
|
||||||
|
(sourceName.isEmpty() ? "" : " from " + sourceName)},
|
||||||
|
.homePage = badgeLink,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return std::make_shared<Emote>(Emote{
|
return std::make_shared<Emote>(Emote{
|
||||||
.name = EmoteName{},
|
.name = EmoteName{},
|
||||||
.images = ImageSet{Image::fromResourcePixmap(
|
.images = ImageSet{Image::fromResourcePixmap(
|
||||||
@@ -2985,22 +3013,33 @@ void MessageBuilder::appendTwitchBadges(const QVariantMap &tags,
|
|||||||
{
|
{
|
||||||
const QString sourceId = tags["source-room-id"].toString();
|
const QString sourceId = tags["source-room-id"].toString();
|
||||||
QString sourceName;
|
QString sourceName;
|
||||||
|
QString sourceProfilePicture;
|
||||||
|
QString sourceLogin;
|
||||||
|
|
||||||
if (sourceId.isEmpty())
|
if (sourceId.isEmpty())
|
||||||
{
|
{
|
||||||
sourceName = "";
|
sourceName = "";
|
||||||
}
|
}
|
||||||
else if (twitchChannel->roomId() == sourceId)
|
|
||||||
{
|
|
||||||
sourceName = twitchChannel->getName();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sourceName =
|
auto twitchUser = getApp()->getTwitchUsers()->resolveID({sourceId});
|
||||||
getApp()->getTwitchUsers()->resolveID({sourceId})->displayName;
|
sourceProfilePicture = twitchUser->profilePictureUrl;
|
||||||
|
sourceLogin = twitchUser->name;
|
||||||
|
|
||||||
|
if (twitchChannel->roomId() == sourceId)
|
||||||
|
{
|
||||||
|
// We have the source channel open, but we still need to load the profile picture URL
|
||||||
|
sourceName = twitchChannel->getName();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sourceName = twitchUser->displayName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->emplace<BadgeElement>(makeSharedChatBadge(sourceName),
|
this->emplace<BadgeElement>(
|
||||||
MessageElementFlag::BadgeSharedChannel);
|
makeSharedChatBadge(sourceName, sourceProfilePicture, sourceLogin),
|
||||||
|
MessageElementFlag::BadgeSharedChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto badgeInfos = parseBadgeInfoTag(tags);
|
auto badgeInfos = parseBadgeInfoTag(tags);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ void TwitchUser::update(const HelixUser &user) const
|
|||||||
assert(this->id == user.id);
|
assert(this->id == user.id);
|
||||||
this->name = user.login;
|
this->name = user.login;
|
||||||
this->displayName = user.displayName;
|
this->displayName = user.displayName;
|
||||||
|
this->profilePictureUrl = user.profileImageUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ struct TwitchUser {
|
|||||||
QString id;
|
QString id;
|
||||||
mutable QString name;
|
mutable QString name;
|
||||||
mutable QString displayName;
|
mutable QString displayName;
|
||||||
|
mutable QString profilePictureUrl;
|
||||||
|
|
||||||
void update(const TwitchUser &other) const
|
void update(const TwitchUser &other) const
|
||||||
{
|
{
|
||||||
@@ -25,6 +26,7 @@ struct TwitchUser {
|
|||||||
|
|
||||||
this->name = other.name;
|
this->name = other.name;
|
||||||
this->displayName = other.displayName;
|
this->displayName = other.displayName;
|
||||||
|
this->profilePictureUrl = other.profilePictureUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(const HelixUser &user) const;
|
void update(const HelixUser &user) const;
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ std::shared_ptr<TwitchUser> TwitchUsersPrivate::makeUnresolved(const UserId &id)
|
|||||||
.id = id.string,
|
.id = id.string,
|
||||||
.name = {},
|
.name = {},
|
||||||
.displayName = {},
|
.displayName = {},
|
||||||
|
.profilePictureUrl = {},
|
||||||
}))
|
}))
|
||||||
.first->second;
|
.first->second;
|
||||||
if (id.string.isEmpty())
|
if (id.string.isEmpty())
|
||||||
|
|||||||
Reference in New Issue
Block a user