mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
minor fixes
This commit is contained in:
parent
c2c3b67f6b
commit
7b192897da
2 changed files with 48 additions and 51 deletions
|
@ -321,7 +321,7 @@ public:
|
||||||
debug::Log("Unhandled request type {}", (int)this->data.requestType);
|
debug::Log("Unhandled request type {}", (int)this->data.requestType);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
} // namespace util
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void useCache()
|
void useCache()
|
||||||
|
@ -372,8 +372,6 @@ private:
|
||||||
if (this->data.caller != nullptr) {
|
if (this->data.caller != nullptr) {
|
||||||
QObject::connect(worker, &NetworkWorker::doneUrl,
|
QObject::connect(worker, &NetworkWorker::doneUrl,
|
||||||
this->data.caller, [data = this->data](auto reply) mutable {
|
this->data.caller, [data = this->data](auto reply) mutable {
|
||||||
auto &dat = data;
|
|
||||||
|
|
||||||
if (reply->error() != QNetworkReply::NetworkError::NoError) {
|
if (reply->error() != QNetworkReply::NetworkError::NoError) {
|
||||||
if (data.onError) {
|
if (data.onError) {
|
||||||
data.onError(reply->error());
|
data.onError(reply->error());
|
||||||
|
@ -389,67 +387,66 @@ private:
|
||||||
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
});
|
});
|
||||||
} // namespace chatterino
|
}
|
||||||
|
|
||||||
if (timer != nullptr) {
|
if (timer != nullptr) {
|
||||||
timer->start(this->data.timeoutMS);
|
timer->start(this->data.timeoutMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject::connect(
|
QObject::connect(&requester, &NetworkRequester::requestUrl, worker,
|
||||||
&requester, &NetworkRequester::requestUrl, worker,
|
[ timer, data = std::move(this->data), worker ]() {
|
||||||
[ timer, data = std::move(this->data), worker ]() {
|
QNetworkReply *reply = nullptr;
|
||||||
QNetworkReply *reply;
|
switch (data.requestType) {
|
||||||
switch (data.requestType) {
|
case GetRequest: {
|
||||||
case GetRequest: {
|
reply = NetworkManager::NaM.get(data.request);
|
||||||
reply = NetworkManager::NaM.get(data.request);
|
} break;
|
||||||
} break;
|
|
||||||
|
|
||||||
case PutRequest: {
|
case PutRequest: {
|
||||||
reply = NetworkManager::NaM.put(data.request, data.payload);
|
reply = NetworkManager::NaM.put(data.request, data.payload);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case DeleteRequest: {
|
case DeleteRequest: {
|
||||||
reply = NetworkManager::NaM.deleteResource(data.request);
|
reply = NetworkManager::NaM.deleteResource(data.request);
|
||||||
} break;
|
} break;
|
||||||
} // namespace chatterino
|
}
|
||||||
|
|
||||||
if (reply == nullptr) {
|
if (reply == nullptr) {
|
||||||
debug::Log("Unhandled request type {}", (int)data.requestType);
|
debug::Log("Unhandled request type {}", (int)data.requestType);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timer != nullptr) {
|
if (timer != nullptr) {
|
||||||
QObject::connect(timer, &QTimer::timeout, worker, [reply, timer, data]() {
|
QObject::connect(timer, &QTimer::timeout, worker,
|
||||||
debug::Log("Aborted!");
|
[reply, timer, data]() {
|
||||||
reply->abort();
|
debug::Log("Aborted!");
|
||||||
timer->deleteLater();
|
reply->abort();
|
||||||
data.onError(-2);
|
timer->deleteLater();
|
||||||
});
|
data.onError(-2);
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (data.onReplyCreated) {
|
if (data.onReplyCreated) {
|
||||||
data.onReplyCreated(reply);
|
data.onReplyCreated(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject::connect(reply, &QNetworkReply::finished, worker,
|
QObject::connect(reply, &QNetworkReply::finished, worker,
|
||||||
[ data = std::move(data), worker, reply ]() mutable {
|
[ data = std::move(data), worker, reply ]() mutable {
|
||||||
if (data.caller == nullptr) {
|
if (data.caller == nullptr) {
|
||||||
QByteArray bytes = reply->readAll();
|
QByteArray bytes = reply->readAll();
|
||||||
data.writeToCache(bytes);
|
data.writeToCache(bytes);
|
||||||
data.onSuccess(parseJSONFromData2(bytes));
|
data.onSuccess(parseJSONFromData2(bytes));
|
||||||
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
} else {
|
} else {
|
||||||
emit worker->doneUrl(reply);
|
emit worker->doneUrl(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete worker;
|
delete worker;
|
||||||
});
|
});
|
||||||
} // namespace util
|
});
|
||||||
);
|
|
||||||
|
|
||||||
emit requester.requestUrl();
|
emit requester.requestUrl();
|
||||||
} // namespace chatterino
|
}
|
||||||
|
|
||||||
void executeGet()
|
void executeGet()
|
||||||
{
|
{
|
||||||
|
@ -467,7 +464,7 @@ private:
|
||||||
{
|
{
|
||||||
this->doRequest();
|
this->doRequest();
|
||||||
}
|
}
|
||||||
}; // namespace util
|
};
|
||||||
|
|
||||||
} // namespace util
|
} // namespace util
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -137,7 +137,7 @@ bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched, QEvent *even
|
||||||
dynamic_cast<QGraphicsOpacityEffect *>(((QWidget *)watched)->graphicsEffect());
|
dynamic_cast<QGraphicsOpacityEffect *>(((QWidget *)watched)->graphicsEffect());
|
||||||
|
|
||||||
if (effect != nullptr) {
|
if (effect != nullptr) {
|
||||||
effect->setOpacity(1);
|
effect->setOpacity(0.99);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->parent->hoveredElement = this->hoveredElement;
|
this->parent->hoveredElement = this->hoveredElement;
|
||||||
|
|
Loading…
Reference in a new issue