diff --git a/chatterino.pro b/chatterino.pro index 1a3cd6d49..82c4f5db9 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -256,7 +256,6 @@ HEADERS += \ src/common/ProviderId.hpp \ src/common/SerializeCustom.hpp \ src/common/SignalVectorModel.hpp \ - src/common/UrlFetch.hpp \ src/common/Version.hpp \ src/controllers/accounts/Account.hpp \ src/controllers/accounts/AccountController.hpp \ diff --git a/src/common/UrlFetch.hpp b/src/common/UrlFetch.hpp deleted file mode 100644 index 5e27fd3d7..000000000 --- a/src/common/UrlFetch.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include "common/NetworkRequest.hpp" - -#include -#include - -namespace chatterino { - -// Not sure if I like these, but I'm trying them out - -static NetworkRequest makeGetChannelRequest(const QString &channelId, - const QObject *caller = nullptr) -{ - QString url("https://api.twitch.tv/kraken/channels/" + channelId); - - auto request = NetworkRequest::twitchRequest(url); - - request.setCaller(caller); - - return request; -} - -static NetworkRequest makeGetStreamRequest(const QString &channelId, - const QObject *caller = nullptr) -{ - QString url("https://api.twitch.tv/kraken/streams/" + channelId); - - auto request = NetworkRequest::twitchRequest(url); - - request.setCaller(caller); - - return request; -} - -} // namespace chatterino diff --git a/src/messages/Image.cpp b/src/messages/Image.cpp index 44b204329..11cd4525c 100644 --- a/src/messages/Image.cpp +++ b/src/messages/Image.cpp @@ -1,8 +1,7 @@ #include "messages/Image.hpp" #include "Application.hpp" -#include "common/NetworkManager.hpp" -#include "common/UrlFetch.hpp" +#include "common/NetworkRequest.hpp" #include "debug/Log.hpp" #include "singletons/Emotes.hpp" #include "singletons/WindowManager.hpp" diff --git a/src/providers/bttv/BttvEmotes.cpp b/src/providers/bttv/BttvEmotes.cpp index 8252ffe37..391be6e6f 100644 --- a/src/providers/bttv/BttvEmotes.cpp +++ b/src/providers/bttv/BttvEmotes.cpp @@ -1,6 +1,6 @@ #include "providers/bttv/BttvEmotes.hpp" -#include "common/UrlFetch.hpp" +#include "common/NetworkRequest.hpp" #include "debug/Log.hpp" #include "messages/Image.hpp" diff --git a/src/providers/ffz/FfzEmotes.cpp b/src/providers/ffz/FfzEmotes.cpp index 25fef15ea..9fe7ac5ce 100644 --- a/src/providers/ffz/FfzEmotes.cpp +++ b/src/providers/ffz/FfzEmotes.cpp @@ -1,6 +1,6 @@ #include "providers/ffz/FfzEmotes.hpp" -#include "common/UrlFetch.hpp" +#include "common/NetworkRequest.hpp" #include "debug/Log.hpp" #include "messages/Image.hpp" diff --git a/src/providers/twitch/TwitchAccount.cpp b/src/providers/twitch/TwitchAccount.cpp index 695bc369f..d5908166c 100644 --- a/src/providers/twitch/TwitchAccount.cpp +++ b/src/providers/twitch/TwitchAccount.cpp @@ -1,7 +1,6 @@ #include "providers/twitch/TwitchAccount.hpp" #include "common/NetworkRequest.hpp" -#include "common/UrlFetch.hpp" #include "debug/Log.hpp" #include "providers/twitch/PartialTwitchUser.hpp" #include "providers/twitch/TwitchCommon.hpp" diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index 4c1285f6f..5092caf0f 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -1,7 +1,7 @@ #include "providers/twitch/TwitchChannel.hpp" #include "common/Common.hpp" -#include "common/UrlFetch.hpp" +#include "common/NetworkRequest.hpp" #include "controllers/accounts/AccountController.hpp" #include "debug/Log.hpp" #include "messages/Message.hpp" @@ -336,7 +336,8 @@ void TwitchChannel::refreshLiveStatus() std::weak_ptr weak = this->shared_from_this(); - auto request = makeGetStreamRequest(this->roomID, QThread::currentThread()); + auto request = NetworkRequest::twitchRequest(url); + request.setCaller(QThread::currentThread()); request.onSuccess([weak](auto result) { auto d = result.parseRapidJson(); diff --git a/src/providers/twitch/TwitchEmotes.cpp b/src/providers/twitch/TwitchEmotes.cpp index d067f320e..3f94a80b3 100644 --- a/src/providers/twitch/TwitchEmotes.cpp +++ b/src/providers/twitch/TwitchEmotes.cpp @@ -1,6 +1,6 @@ #include "providers/twitch/TwitchEmotes.hpp" -#include "common/UrlFetch.hpp" +#include "common/NetworkRequest.hpp" #include "debug/Benchmark.hpp" #include "debug/Log.hpp" #include "messages/Image.hpp" diff --git a/src/widgets/dialogs/LoginDialog.cpp b/src/widgets/dialogs/LoginDialog.cpp index 14fa58dcb..bee0e87b0 100644 --- a/src/widgets/dialogs/LoginDialog.cpp +++ b/src/widgets/dialogs/LoginDialog.cpp @@ -1,7 +1,7 @@ #include "widgets/dialogs/LoginDialog.hpp" #include "common/Common.hpp" -#include "common/UrlFetch.hpp" +#include "common/NetworkRequest.hpp" #include "controllers/accounts/AccountController.hpp" #include "providers/twitch/PartialTwitchUser.hpp" diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index 02ae86703..edddede5e 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -1,7 +1,7 @@ #include "UserInfoPopup.hpp" #include "Application.hpp" -#include "common/UrlFetch.hpp" +#include "common/NetworkRequest.hpp" #include "controllers/accounts/AccountController.hpp" #include "providers/twitch/PartialTwitchUser.hpp" #include "providers/twitch/TwitchChannel.hpp" @@ -250,7 +250,10 @@ void UserInfoPopup::updateUserData() this->userId_ = id; - auto request = makeGetChannelRequest(id, this); + QString url("https://api.twitch.tv/kraken/channels/" + id); + + auto request = NetworkRequest::twitchRequest(url); + request.setCaller(this); request.onSuccess([this](auto result) { auto obj = result.parseJson(); diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index efa6fbc77..1ccdf63ed 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -2,7 +2,7 @@ #include "Application.hpp" #include "common/Common.hpp" -#include "common/UrlFetch.hpp" +#include "common/NetworkRequest.hpp" #include "providers/twitch/EmoteValue.hpp" #include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/TwitchMessageBuilder.hpp" @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index e37938302..78251a303 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -1,7 +1,6 @@ #include "widgets/splits/SplitHeader.hpp" #include "Application.hpp" -#include "common/UrlFetch.hpp" #include "controllers/accounts/AccountController.hpp" #include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/TwitchServer.hpp" @@ -80,9 +79,7 @@ SplitHeader::SplitHeader(Split *_split) // dropdown->setScaleIndependantSize(23, 23); this->addDropdownItems(dropdown.getElement()); QObject::connect(dropdown.getElement(), &RippleEffectButton::leftMousePress, this, [this] { - QTimer::singleShot(80, [&, this] { - this->dropdownMenu_.popup(QCursor::pos()); - }); + QTimer::singleShot(80, [&, this] { this->dropdownMenu_.popup(QCursor::pos()); }); }); } diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index 70efdd77b..113a05d7a 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -1,7 +1,6 @@ #include "widgets/splits/SplitInput.hpp" #include "Application.hpp" -#include "common/UrlFetch.hpp" #include "controllers/commands/CommandController.hpp" #include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/TwitchServer.hpp"