Make use of QUrlQuery in NetworkRequests where it was hardcoded into url (#3039)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
Paweł 2021-07-18 15:21:09 +02:00 committed by GitHub
parent e5fe0999ee
commit ae9f92ded9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View file

@ -7,6 +7,7 @@
#include <QJsonObject>
#include <QJsonValue>
#include <QThread>
#include <QUrlQuery>
#include "common/NetworkRequest.hpp"
#include "common/Outcome.hpp"
@ -24,8 +25,11 @@ void TwitchBadges::loadTwitchBadges()
{
assert(this->loaded_ == false);
static QString url(
"https://badges.twitch.tv/v1/badges/global/display?language=en");
QUrl url("https://badges.twitch.tv/v1/badges/global/display");
QUrlQuery urlQuery;
urlQuery.addQueryItem("language", "en");
url.setQuery(urlQuery);
NetworkRequest(url)
.onSuccess([this](auto result) -> Outcome {

View file

@ -755,11 +755,14 @@ void TwitchChannel::loadRecentMessages()
return;
}
auto baseURL = Env::get().recentMessagesApiUrl.arg(this->getName());
auto url = QString("%1?limit=%2")
.arg(baseURL)
.arg(getSettings()->twitchMessageHistoryLimit);
QUrl url(Env::get().recentMessagesApiUrl.arg(this->getName()));
QUrlQuery urlQuery(url);
if (!urlQuery.hasQueryItem("limit"))
{
urlQuery.addQueryItem(
"limit", QString::number(getSettings()->twitchMessageHistoryLimit));
}
url.setQuery(urlQuery);
auto weak = weakOf<Channel>(this);