tidy&format(all): all files formatted and relevant warnings resolved
C++ / build (pull_request) Failing after 15s
Lint & Format (JS/TS) / lint-format (pull_request) Successful in 28s
Python / lint-format (pull_request) Successful in 45s
Python / test (pull_request) Successful in 38s
Lint & Format (Rust) / lint-format (pull_request) Successful in 1m45s
C++ / build (pull_request) Failing after 15s
Lint & Format (JS/TS) / lint-format (pull_request) Successful in 28s
Python / lint-format (pull_request) Successful in 45s
Python / test (pull_request) Successful in 38s
Lint & Format (Rust) / lint-format (pull_request) Successful in 1m45s
This commit is contained in:
@@ -7,9 +7,7 @@
|
||||
namespace ZShell {
|
||||
|
||||
Requests::Requests(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_manager(new QNetworkAccessManager(this)) {
|
||||
}
|
||||
: QObject(parent), m_manager(new QNetworkAccessManager(this)) {}
|
||||
|
||||
void Requests::get(const QUrl& url, QJSValue onSuccess, QJSValue onError) const {
|
||||
if (!onSuccess.isCallable()) {
|
||||
@@ -20,13 +18,15 @@ void Requests::get(const QUrl& url, QJSValue onSuccess, QJSValue onError) const
|
||||
QNetworkRequest request(url);
|
||||
auto reply = m_manager->get(request);
|
||||
|
||||
QObject::connect(reply, &QNetworkReply::finished, [reply, onSuccess, onError]() {
|
||||
QObject::connect(
|
||||
reply, &QNetworkReply::finished, [reply, onSuccess, onError]() {
|
||||
if (reply->error() == QNetworkReply::NoError) {
|
||||
onSuccess.call({ QString(reply->readAll()) });
|
||||
onSuccess.call({QString(reply->readAll())});
|
||||
} else if (onError.isCallable()) {
|
||||
onError.call({ reply->errorString() });
|
||||
onError.call({reply->errorString()});
|
||||
} else {
|
||||
qWarning() << "Requests::get: request failed with error" << reply->errorString();
|
||||
qWarning() << "Requests::get: request failed with error"
|
||||
<< reply->errorString();
|
||||
}
|
||||
|
||||
reply->deleteLater();
|
||||
|
||||
Reference in New Issue
Block a user