ui/map: update destination on param change (#28957)

* update destination on param change

* use ParamWatcher

* remove include
old-commit-hash: d47d8808d1
This commit is contained in:
Dean Lee 2023-07-17 04:48:33 +08:00 committed by GitHub
parent 80e7b739b4
commit e8478e81c7
2 changed files with 6 additions and 3 deletions

View File

@ -299,6 +299,9 @@ NavigationRequest::NavigationRequest(QObject *parent) : QObject(parent) {
QObject::connect(repeater, &RequestRepeater::requestDone, this, &NavigationRequest::parseLocationsResponse);
}
{
auto param_watcher = new ParamWatcher(this);
QObject::connect(param_watcher, &ParamWatcher::paramChanged, this, &NavigationRequest::nextDestinationUpdated);
// Destination set while offline
QString url = CommaApi::BASE_URL + "/v1/navigation/" + *dongle_id + "/next";
HttpRequest *deleter = new HttpRequest(this);
@ -315,8 +318,8 @@ NavigationRequest::NavigationRequest(QObject *parent) : QObject(parent) {
deleter->sendRequest(url, HttpRequest::Method::DELETE);
}
// Update UI (athena can set destination at any time)
emit nextDestinationUpdated(resp, success);
// athena can set destination at any time
param_watcher->addParam("NavDestination");
});
}
}

View File

@ -29,7 +29,7 @@ public:
signals:
void locationsUpdated(const QJsonArray &locations);
void nextDestinationUpdated(const QString &response, bool success);
void nextDestinationUpdated();
private:
NavigationRequest(QObject *parent);