From 57737b1b72b26935c76b57a285e7fa86f66fecc9 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 30 Dec 2023 04:42:06 +0100 Subject: [PATCH] [Entities UI] Don't disable/set loading=true on properties during initial refresh. --- .../src/components/panels/Entities/Index.vue | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/platypush/backend/http/webapp/src/components/panels/Entities/Index.vue b/platypush/backend/http/webapp/src/components/panels/Entities/Index.vue index e70798e2ad..d8ad6f0dcc 100644 --- a/platypush/backend/http/webapp/src/components/panels/Entities/Index.vue +++ b/platypush/backend/http/webapp/src/components/panels/Entities/Index.vue @@ -235,7 +235,7 @@ export default { delete this.selector.selectedGroups[group.name] }, - async refresh(group) { + async refresh(group, setLoading=true) { const entities = (group ? group.entities : this.entities) || {} const args = {} if (group) @@ -244,29 +244,30 @@ export default { return obj }, {}) - this.loadingEntities = Object.values(entities).reduce((obj, entity) => { - if (this._shouldSkipLoading(entity)) + if (setLoading) + this.loadingEntities = Object.values(entities).reduce((obj, entity) => { + if (this._shouldSkipLoading(entity)) + return obj + + const self = this + const id = entity.id + if (this.entityTimeouts[id]) + clearTimeout(this.entityTimeouts[id]) + + this.addEntity(entity) + this.entityTimeouts[id] = setTimeout(() => { + if (self.loadingEntities[id]) + delete self.loadingEntities[id] + if (self.entityTimeouts[id]) + delete self.entityTimeouts[id] + + self.errorEntities[id] = entity + console.warn(`Scan timeout for ${entity.name}`) + }, this.entityScanTimeout * 1000) + + obj[id] = true return obj - - const self = this - const id = entity.id - if (this.entityTimeouts[id]) - clearTimeout(this.entityTimeouts[id]) - - this.addEntity(entity) - this.entityTimeouts[id] = setTimeout(() => { - if (self.loadingEntities[id]) - delete self.loadingEntities[id] - if (self.entityTimeouts[id]) - delete self.entityTimeouts[id] - - self.errorEntities[id] = entity - console.warn(`Scan timeout for ${entity.name}`) - }, this.entityScanTimeout * 1000) - - obj[id] = true - return obj - }, {}) + }, {}) this.request('entities.scan', args) }, @@ -428,7 +429,7 @@ export default { const hasCachedEntities = this.loadCachedEntities() await this.sync(!hasCachedEntities) - await this.refresh() + await this.refresh(null, !hasCachedEntities) setInterval(() => this.refreshEntitiesCache(), 10000) },