fix: use static version of 7tv badges (#5674)

This commit is contained in:
pajlada
2024-10-24 10:26:20 +02:00
committed by GitHub
parent 9e8281b75b
commit f66bc37368
4 changed files with 33 additions and 11 deletions
+28 -9
View File
@@ -106,12 +106,18 @@ CreateEmoteResult createEmote(const QJsonObject &activeEmote,
? createAliasedTooltip(emoteName.string, baseEmoteName.string,
author.string, isGlobal)
: createTooltip(emoteName.string, author.string, isGlobal);
auto imageSet = SeventvEmotes::createImageSet(emoteData);
auto imageSet = SeventvEmotes::createImageSet(emoteData, false);
auto emote =
Emote({emoteName, imageSet, tooltip,
Url{EMOTE_LINK_FORMAT.arg(emoteId.string)}, zeroWidth, emoteId,
author, makeConditionedOptional(aliasedName, baseEmoteName)});
auto emote = Emote({
emoteName,
imageSet,
tooltip,
Url{EMOTE_LINK_FORMAT.arg(emoteId.string)},
zeroWidth,
emoteId,
author,
makeConditionedOptional(aliasedName, baseEmoteName),
});
return {emote, emoteId, emoteName, !emote.images.getImage1()->isEmpty()};
}
@@ -427,7 +433,8 @@ void SeventvEmotes::getEmoteSet(
});
}
ImageSet SeventvEmotes::createImageSet(const QJsonObject &emoteData)
ImageSet SeventvEmotes::createImageSet(const QJsonObject &emoteData,
bool useStatic)
{
auto host = emoteData["host"].toObject();
// "//cdn.7tv[...]"
@@ -463,9 +470,21 @@ ImageSet SeventvEmotes::createImageSet(const QJsonObject &emoteData)
baseWidth = width;
}
auto image = Image::fromUrl(
{QString("https:%1/%2").arg(baseUrl, file["name"].toString())},
scale, {static_cast<int>(width), file["height"].toInt(16)});
auto name = [&] {
if (useStatic)
{
auto staticName = file["static_name"].toString();
if (!staticName.isEmpty())
{
return staticName;
}
}
return file["name"].toString();
}();
auto image =
Image::fromUrl({QString("https:%1/%2").arg(baseUrl, name)}, scale,
{static_cast<int>(width), file["height"].toInt(16)});
sizes.at(nextSize) = image;
nextSize++;