mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 09:16:38 +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) {
|
apiCalled: function (ev) {
|
||||||
if (ev.detail.success) {
|
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 () {
|
refresh: function () {
|
||||||
this.fetchSupervisorInfo();
|
return Promise.all([
|
||||||
this.fetchHostInfo();
|
this.fetchSupervisorInfo(),
|
||||||
this.fetchHassInfo();
|
this.fetchHostInfo(),
|
||||||
|
this.fetchHassInfo(),
|
||||||
|
])
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchSupervisorInfo: function () {
|
fetchSupervisorInfo: function () {
|
||||||
this.hass.callApi('get', 'hassio/supervisor/info')
|
return this.hass.callApi('get', 'hassio/supervisor/info')
|
||||||
.then(function (info) {
|
.then(function (info) {
|
||||||
this.supervisor = info.data;
|
this.supervisor = info.data;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchHostInfo: function () {
|
fetchHostInfo: function () {
|
||||||
this.hass.callApi('get', 'hassio/host/info')
|
return this.hass.callApi('get', 'hassio/host/info')
|
||||||
.then(function (info) {
|
.then(function (info) {
|
||||||
this.host = info.data;
|
this.host = info.data;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchHassInfo: function () {
|
fetchHassInfo: function () {
|
||||||
this.hass.callApi('get', 'hassio/homeassistant/info')
|
return this.hass.callApi('get', 'hassio/homeassistant/info')
|
||||||
.then(function (info) {
|
.then(function (info) {
|
||||||
this.homeassistant = info.data;
|
this.homeassistant = info.data;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user