fix: Twitch global emotes not loading (#5144)

This commit is contained in:
pajlada 2024-02-02 15:28:27 +01:00 committed by GitHub
parent d0c321e19f
commit ab7e6e0281
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 8 additions and 16 deletions

View file

@ -113,7 +113,7 @@
- Dev: Move `clang-tidy` checker to its own CI job. (#4996) - Dev: Move `clang-tidy` checker to its own CI job. (#4996)
- Dev: Refactored the Image Uploader feature. (#4971) - Dev: Refactored the Image Uploader feature. (#4971)
- Dev: Refactored the SplitOverlay code. (#5082) - Dev: Refactored the SplitOverlay code. (#5082)
- Dev: Refactored the TwitchBadges structure, making it less of a singleton. (#5096) - Dev: Refactored the TwitchBadges structure, making it less of a singleton. (#5096, #5144)
- Dev: Refactored emotes out of TwitchIrcServer. (#5120) - Dev: Refactored emotes out of TwitchIrcServer. (#5120)
- Dev: Refactored the ChatterinoBadges structure, making it less of a singleton. (#5103) - Dev: Refactored the ChatterinoBadges structure, making it less of a singleton. (#5103)
- Dev: Refactored the ColorProvider class a bit. (#5112) - Dev: Refactored the ColorProvider class a bit. (#5112)

File diff suppressed because one or more lines are too long

View file

@ -204,6 +204,10 @@ void Application::initialize(Settings &settings, const Paths &paths)
singleton->initialize(settings, paths); singleton->initialize(settings, paths);
} }
// XXX: Loading Twitch badges after Helix has been initialized, which only happens after
// the AccountController initialize has been called
this->twitchBadges->loadTwitchBadges();
// Show crash message. // Show crash message.
// On Windows, the crash message was already shown. // On Windows, the crash message was already shown.
#ifndef Q_OS_WIN #ifndef Q_OS_WIN

View file

@ -20,21 +20,10 @@
namespace chatterino { namespace chatterino {
TwitchBadges::TwitchBadges()
{
this->loadTwitchBadges();
}
void TwitchBadges::loadTwitchBadges() void TwitchBadges::loadTwitchBadges()
{ {
assert(this->loaded_ == false); assert(this->loaded_ == false);
if (!getHelix())
{
// This is intended for tests and benchmarks.
return;
}
getHelix()->getGlobalBadges( getHelix()->getGlobalBadges(
[this](auto globalBadges) { [this](auto globalBadges) {
auto badgeSets = this->badgeSets_.access(); auto badgeSets = this->badgeSets_.access();

View file

@ -32,8 +32,6 @@ class TwitchBadges
using BadgeIconCallback = std::function<void(QString, const QIconPtr)>; using BadgeIconCallback = std::function<void(QString, const QIconPtr)>;
public: public:
TwitchBadges();
// Get badge from name and version // Get badge from name and version
std::optional<EmotePtr> badge(const QString &set, std::optional<EmotePtr> badge(const QString &set,
const QString &version) const; const QString &version) const;
@ -45,8 +43,9 @@ public:
void getBadgeIcons(const QList<DisplayBadge> &badges, void getBadgeIcons(const QList<DisplayBadge> &badges,
BadgeIconCallback callback); BadgeIconCallback callback);
private:
void loadTwitchBadges(); void loadTwitchBadges();
private:
void parseTwitchBadges(QJsonObject root); void parseTwitchBadges(QJsonObject root);
void loaded(); void loaded();
void loadEmoteImage(const QString &name, ImagePtr image, void loadEmoteImage(const QString &name, ImagePtr image,