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: Refactored the Image Uploader feature. (#4971)
- 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 the ChatterinoBadges structure, making it less of a singleton. (#5103)
- 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);
}
// 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.
// On Windows, the crash message was already shown.
#ifndef Q_OS_WIN

View file

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

View file

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