chore: remove Singleton & replace getIApp with getApp (#5514)

This commit is contained in:
pajlada
2024-07-21 15:09:59 +02:00
committed by GitHub
parent 21186df058
commit 5deec1f02f
145 changed files with 802 additions and 856 deletions
+2 -4
View File
@@ -1,7 +1,5 @@
#pragma once
#include "common/Singleton.hpp"
#include <functional>
class QString;
@@ -11,7 +9,7 @@ namespace chatterino {
class NetworkResult;
class SeventvAPI : public Singleton
class SeventvAPI final
{
using ErrorCallback = std::function<void(const NetworkResult &)>;
template <typename... T>
@@ -19,7 +17,7 @@ class SeventvAPI : public Singleton
public:
SeventvAPI() = default;
~SeventvAPI() override = default;
~SeventvAPI() = default;
SeventvAPI(const SeventvAPI &) = delete;
SeventvAPI(SeventvAPI &&) = delete;
+1 -2
View File
@@ -1,7 +1,6 @@
#pragma once
#include "common/Aliases.hpp"
#include "common/Singleton.hpp"
#include "util/QStringHash.hpp"
#include <QJsonObject>
@@ -16,7 +15,7 @@ namespace chatterino {
struct Emote;
using EmotePtr = std::shared_ptr<const Emote>;
class SeventvBadges : public Singleton
class SeventvBadges
{
public:
// Return the badge, if any, that is assigned to the user
+3 -3
View File
@@ -217,7 +217,7 @@ void SeventvEmotes::loadGlobalEmotes()
qCDebug(chatterinoSeventv) << "Loading 7TV Global Emotes";
getIApp()->getSeventvAPI()->getEmoteSet(
getApp()->getSeventvAPI()->getEmoteSet(
u"global"_s,
[this](const auto &json) {
QJsonArray parsedEmotes = json["emotes"].toArray();
@@ -246,7 +246,7 @@ void SeventvEmotes::loadChannelEmotes(
qCDebug(chatterinoSeventv)
<< "Reloading 7TV Channel Emotes" << channelId << manualRefresh;
getIApp()->getSeventvAPI()->getUserByTwitchID(
getApp()->getSeventvAPI()->getUserByTwitchID(
channelId,
[callback = std::move(callback), channel, channelId,
manualRefresh](const auto &json) {
@@ -405,7 +405,7 @@ void SeventvEmotes::getEmoteSet(
{
qCDebug(chatterinoSeventv) << "Loading 7TV Emote Set" << emoteSetId;
getIApp()->getSeventvAPI()->getEmoteSet(
getApp()->getSeventvAPI()->getEmoteSet(
emoteSetId,
[callback = std::move(successCallback), emoteSetId](const auto &json) {
auto parsedEmotes = json["emotes"].toArray();
+3 -3
View File
@@ -348,7 +348,7 @@ void SeventvEventAPI::onUserUpdate(const Dispatch &dispatch)
void SeventvEventAPI::onCosmeticCreate(const CosmeticCreateDispatch &cosmetic)
{
auto *badges = getIApp()->getSeventvBadges();
auto *badges = getApp()->getSeventvBadges();
switch (cosmetic.kind)
{
case CosmeticKind::Badge: {
@@ -363,7 +363,7 @@ void SeventvEventAPI::onCosmeticCreate(const CosmeticCreateDispatch &cosmetic)
void SeventvEventAPI::onEntitlementCreate(
const EntitlementCreateDeleteDispatch &entitlement)
{
auto *badges = getIApp()->getSeventvBadges();
auto *badges = getApp()->getSeventvBadges();
switch (entitlement.kind)
{
case CosmeticKind::Badge: {
@@ -379,7 +379,7 @@ void SeventvEventAPI::onEntitlementCreate(
void SeventvEventAPI::onEntitlementDelete(
const EntitlementCreateDeleteDispatch &entitlement)
{
auto *badges = getIApp()->getSeventvBadges();
auto *badges = getApp()->getSeventvBadges();
switch (entitlement.kind)
{
case CosmeticKind::Badge: {