refactor: move seventv/bttv event apis to application (#5532)
This commit is contained in:
@@ -146,15 +146,14 @@ TwitchChannel::~TwitchChannel()
|
||||
getApp()->getTwitch()->dropSeventvChannel(this->seventvUserID_,
|
||||
this->seventvEmoteSetID_);
|
||||
|
||||
if (getApp()->getTwitch()->getBTTVLiveUpdates())
|
||||
if (getApp()->getBttvLiveUpdates())
|
||||
{
|
||||
getApp()->getTwitch()->getBTTVLiveUpdates()->partChannel(
|
||||
this->roomId());
|
||||
getApp()->getBttvLiveUpdates()->partChannel(this->roomId());
|
||||
}
|
||||
|
||||
if (getApp()->getTwitch()->getSeventvEventAPI())
|
||||
if (getApp()->getSeventvEventAPI())
|
||||
{
|
||||
getApp()->getTwitch()->getSeventvEventAPI()->unsubscribeTwitchChannel(
|
||||
getApp()->getSeventvEventAPI()->unsubscribeTwitchChannel(
|
||||
this->roomId());
|
||||
}
|
||||
}
|
||||
@@ -854,7 +853,7 @@ const QString &TwitchChannel::seventvEmoteSetID() const
|
||||
|
||||
void TwitchChannel::joinBttvChannel() const
|
||||
{
|
||||
if (getApp()->getTwitch()->getBTTVLiveUpdates())
|
||||
if (getApp()->getBttvLiveUpdates())
|
||||
{
|
||||
const auto currentAccount =
|
||||
getApp()->getAccounts()->twitch.getCurrent();
|
||||
@@ -863,8 +862,7 @@ void TwitchChannel::joinBttvChannel() const
|
||||
{
|
||||
userName = currentAccount->getUserName();
|
||||
}
|
||||
getApp()->getTwitch()->getBTTVLiveUpdates()->joinChannel(this->roomId(),
|
||||
userName);
|
||||
getApp()->getBttvLiveUpdates()->joinChannel(this->roomId(), userName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1012,9 +1010,9 @@ void TwitchChannel::updateSeventvData(const QString &newUserID,
|
||||
this->seventvUserID_ = newUserID;
|
||||
this->seventvEmoteSetID_ = newEmoteSetID;
|
||||
runInGuiThread([this, oldUserID, oldEmoteSetID]() {
|
||||
if (getApp()->getTwitch()->getSeventvEventAPI())
|
||||
if (getApp()->getSeventvEventAPI())
|
||||
{
|
||||
getApp()->getTwitch()->getSeventvEventAPI()->subscribeUser(
|
||||
getApp()->getSeventvEventAPI()->subscribeUser(
|
||||
this->seventvUserID_, this->seventvEmoteSetID_);
|
||||
|
||||
if (oldUserID || oldEmoteSetID)
|
||||
@@ -1811,10 +1809,9 @@ void TwitchChannel::updateSevenTVActivity()
|
||||
|
||||
void TwitchChannel::listenSevenTVCosmetics() const
|
||||
{
|
||||
if (getApp()->getTwitch()->getSeventvEventAPI())
|
||||
if (getApp()->getSeventvEventAPI())
|
||||
{
|
||||
getApp()->getTwitch()->getSeventvEventAPI()->subscribeTwitchChannel(
|
||||
this->roomId());
|
||||
getApp()->getSeventvEventAPI()->subscribeTwitchChannel(this->roomId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,6 @@ namespace {
|
||||
|
||||
using namespace chatterino;
|
||||
|
||||
const QString BTTV_LIVE_UPDATES_URL = "wss://sockets.betterttv.net/ws";
|
||||
const QString SEVENTV_EVENTAPI_URL = "wss://events.7tv.io/v3";
|
||||
|
||||
void sendHelixMessage(const std::shared_ptr<TwitchChannel> &channel,
|
||||
const QString &message, const QString &replyParentId = {})
|
||||
{
|
||||
@@ -145,20 +142,6 @@ TwitchIrcServer::TwitchIrcServer()
|
||||
{
|
||||
this->initializeIrc();
|
||||
|
||||
if (getSettings()->enableBTTVLiveUpdates &&
|
||||
getSettings()->enableBTTVChannelEmotes)
|
||||
{
|
||||
this->bttvLiveUpdates =
|
||||
std::make_unique<BttvLiveUpdates>(BTTV_LIVE_UPDATES_URL);
|
||||
}
|
||||
|
||||
if (getSettings()->enableSevenTVEventAPI &&
|
||||
getSettings()->enableSevenTVChannelEmotes)
|
||||
{
|
||||
this->seventvEventAPI =
|
||||
std::make_unique<SeventvEventAPI>(SEVENTV_EVENTAPI_URL);
|
||||
}
|
||||
|
||||
// getSettings()->twitchSeperateWriteConnection.connect([this](auto, auto) {
|
||||
// this->connect(); },
|
||||
// this->signalHolder_,
|
||||
@@ -638,16 +621,6 @@ void TwitchIrcServer::onReplySendRequested(
|
||||
sent = true;
|
||||
}
|
||||
|
||||
std::unique_ptr<BttvLiveUpdates> &TwitchIrcServer::getBTTVLiveUpdates()
|
||||
{
|
||||
return this->bttvLiveUpdates;
|
||||
}
|
||||
|
||||
std::unique_ptr<SeventvEventAPI> &TwitchIrcServer::getSeventvEventAPI()
|
||||
{
|
||||
return this->seventvEventAPI;
|
||||
}
|
||||
|
||||
const IndirectChannel &TwitchIrcServer::getWatchingChannel() const
|
||||
{
|
||||
return this->watchingChannel;
|
||||
@@ -759,7 +732,7 @@ void TwitchIrcServer::forEachSeventvUser(
|
||||
void TwitchIrcServer::dropSeventvChannel(const QString &userID,
|
||||
const QString &emoteSetID)
|
||||
{
|
||||
if (!this->seventvEventAPI)
|
||||
if (!getApp()->getSeventvEventAPI())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -798,11 +771,11 @@ void TwitchIrcServer::dropSeventvChannel(const QString &userID,
|
||||
|
||||
if (!foundUser)
|
||||
{
|
||||
this->seventvEventAPI->unsubscribeUser(userID);
|
||||
getApp()->getSeventvEventAPI()->unsubscribeUser(userID);
|
||||
}
|
||||
if (!foundSet)
|
||||
{
|
||||
this->seventvEventAPI->unsubscribeEmoteSet(emoteSetID);
|
||||
getApp()->getSeventvEventAPI()->unsubscribeEmoteSet(emoteSetID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ namespace chatterino {
|
||||
class Settings;
|
||||
class Paths;
|
||||
class TwitchChannel;
|
||||
class BttvLiveUpdates;
|
||||
class SeventvEventAPI;
|
||||
class BttvEmotes;
|
||||
class FfzEmotes;
|
||||
class SeventvEmotes;
|
||||
@@ -35,9 +33,6 @@ public:
|
||||
virtual void dropSeventvChannel(const QString &userID,
|
||||
const QString &emoteSetID) = 0;
|
||||
|
||||
virtual std::unique_ptr<BttvLiveUpdates> &getBTTVLiveUpdates() = 0;
|
||||
virtual std::unique_ptr<SeventvEventAPI> &getSeventvEventAPI() = 0;
|
||||
|
||||
virtual const IndirectChannel &getWatchingChannel() const = 0;
|
||||
virtual void setWatchingChannel(ChannelPtr newWatchingChannel) = 0;
|
||||
virtual ChannelPtr getWhispersChannel() const = 0;
|
||||
@@ -102,13 +97,7 @@ private:
|
||||
const ChannelPtr automodChannel;
|
||||
IndirectChannel watchingChannel;
|
||||
|
||||
std::unique_ptr<BttvLiveUpdates> bttvLiveUpdates;
|
||||
std::unique_ptr<SeventvEventAPI> seventvEventAPI;
|
||||
|
||||
public:
|
||||
std::unique_ptr<BttvLiveUpdates> &getBTTVLiveUpdates() override;
|
||||
std::unique_ptr<SeventvEventAPI> &getSeventvEventAPI() override;
|
||||
|
||||
const IndirectChannel &getWatchingChannel() const override;
|
||||
void setWatchingChannel(ChannelPtr newWatchingChannel) override;
|
||||
ChannelPtr getWhispersChannel() const override;
|
||||
|
||||
Reference in New Issue
Block a user