Fix RequestRepeater caching (#21693)

* Fix RequestRepeater caching

* cleanup

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: ca51b3865fa360a7a9b69a0748ee92033ac9520c
This commit is contained in:
Adeeb Shihadeh
2021-07-22 22:14:32 -07:00
committed by GitHub
parent 02f1895b7d
commit 4720bafdb3
+1 -7
View File
@@ -15,7 +15,7 @@ RequestRepeater::RequestRepeater(QObject *parent, const QString &requestURL, con
if (!cacheKey.isEmpty()) {
prevResp = QString::fromStdString(params.get(cacheKey.toStdString()));
if (!prevResp.isEmpty()) {
QTimer::singleShot(0, [=]() { emit receivedResponse(prevResp); });
QTimer::singleShot(500, [=]() { emit receivedResponse(prevResp); });
}
QObject::connect(this, &HttpRequest::receivedResponse, [=](const QString &resp) {
if (resp != prevResp) {
@@ -23,11 +23,5 @@ RequestRepeater::RequestRepeater(QObject *parent, const QString &requestURL, con
prevResp = resp;
}
});
QObject::connect(this, &HttpRequest::failedResponse, [=](const QString &err) {
if (!prevResp.isEmpty()) {
params.remove(cacheKey.toStdString());
prevResp = "";
}
});
}
}