mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 01:06:35 +00:00
Keep trying to refresh data after successful API call
This commit is contained in:
parent
28f3a23acc
commit
6d5a911cb5
@ -127,7 +127,16 @@ Polymer({
|
||||
|
||||
apiCalled: function (ev) {
|
||||
if (ev.detail.success) {
|
||||
this.$.data.refresh();
|
||||
var tries = 1;
|
||||
|
||||
var tryUpdate = function () {
|
||||
this.$.data.refresh().catch(function () {
|
||||
tries += 1;
|
||||
setTimeout(tryUpdate, Math.min(tries, 5) * 1000);
|
||||
})
|
||||
}.bind(this);
|
||||
|
||||
tryUpdate();
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -29,27 +29,29 @@ Polymer({
|
||||
},
|
||||
|
||||
refresh: function () {
|
||||
this.fetchSupervisorInfo();
|
||||
this.fetchHostInfo();
|
||||
this.fetchHassInfo();
|
||||
return Promise.all([
|
||||
this.fetchSupervisorInfo(),
|
||||
this.fetchHostInfo(),
|
||||
this.fetchHassInfo(),
|
||||
])
|
||||
},
|
||||
|
||||
fetchSupervisorInfo: function () {
|
||||
this.hass.callApi('get', 'hassio/supervisor/info')
|
||||
return this.hass.callApi('get', 'hassio/supervisor/info')
|
||||
.then(function (info) {
|
||||
this.supervisor = info.data;
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
fetchHostInfo: function () {
|
||||
this.hass.callApi('get', 'hassio/host/info')
|
||||
return this.hass.callApi('get', 'hassio/host/info')
|
||||
.then(function (info) {
|
||||
this.host = info.data;
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
fetchHassInfo: function () {
|
||||
this.hass.callApi('get', 'hassio/homeassistant/info')
|
||||
return this.hass.callApi('get', 'hassio/homeassistant/info')
|
||||
.then(function (info) {
|
||||
this.homeassistant = info.data;
|
||||
}.bind(this));
|
||||
|
Loading…
x
Reference in New Issue
Block a user