fix: deadlock and use-after-free in tests (#4981)
* fix: use-after-free in settings * refactor: put seventv api into a singleton * chore: add changelog entry * Add warning for when the 7TV load fails
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/Singleton.hpp"
|
||||
|
||||
#include <functional>
|
||||
|
||||
class QString;
|
||||
@@ -9,25 +11,33 @@ namespace chatterino {
|
||||
|
||||
class NetworkResult;
|
||||
|
||||
class SeventvAPI
|
||||
class SeventvAPI : public Singleton
|
||||
{
|
||||
using ErrorCallback = std::function<void(const NetworkResult &)>;
|
||||
template <typename... T>
|
||||
using SuccessCallback = std::function<void(T...)>;
|
||||
|
||||
public:
|
||||
void getUserByTwitchID(const QString &twitchID,
|
||||
SuccessCallback<const QJsonObject &> &&onSuccess,
|
||||
ErrorCallback &&onError);
|
||||
void getEmoteSet(const QString &emoteSet,
|
||||
SuccessCallback<const QJsonObject &> &&onSuccess,
|
||||
ErrorCallback &&onError);
|
||||
SeventvAPI() = default;
|
||||
~SeventvAPI() override = default;
|
||||
|
||||
void updatePresence(const QString &twitchChannelID,
|
||||
const QString &seventvUserID,
|
||||
SuccessCallback<> &&onSuccess, ErrorCallback &&onError);
|
||||
SeventvAPI(const SeventvAPI &) = delete;
|
||||
SeventvAPI(SeventvAPI &&) = delete;
|
||||
SeventvAPI &operator=(const SeventvAPI &) = delete;
|
||||
SeventvAPI &operator=(SeventvAPI &&) = delete;
|
||||
|
||||
virtual void getUserByTwitchID(
|
||||
const QString &twitchID,
|
||||
SuccessCallback<const QJsonObject &> &&onSuccess,
|
||||
ErrorCallback &&onError);
|
||||
virtual void getEmoteSet(const QString &emoteSet,
|
||||
SuccessCallback<const QJsonObject &> &&onSuccess,
|
||||
ErrorCallback &&onError);
|
||||
|
||||
virtual void updatePresence(const QString &twitchChannelID,
|
||||
const QString &seventvUserID,
|
||||
SuccessCallback<> &&onSuccess,
|
||||
ErrorCallback &&onError);
|
||||
};
|
||||
|
||||
SeventvAPI &getSeventvAPI();
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user