do not reload if already loaded or loading

This commit is contained in:
mike-000
2022-04-23 11:57:22 +01:00
committed by Tim Schaub
parent 36ec95677d
commit 0ef7c40b8e
+19 -14
View File
@@ -75,21 +75,26 @@ class DataTile extends Tile {
* @api * @api
*/ */
load() { load() {
this.state = TileState.LOADING; if (this.state == TileState.ERROR) {
this.changed(); this.state = TileState.IDLE;
}
if (this.state == TileState.IDLE) {
this.state = TileState.LOADING;
this.changed();
const self = this; const self = this;
this.loader_() this.loader_()
.then(function (data) { .then(function (data) {
self.data_ = data; self.data_ = data;
self.state = TileState.LOADED; self.state = TileState.LOADED;
self.changed(); self.changed();
}) })
.catch(function (error) { .catch(function (error) {
self.error_ = error; self.error_ = error;
self.state = TileState.ERROR; self.state = TileState.ERROR;
self.changed(); self.changed();
}); });
}
} }
} }