[Entities UI] Don't disable/set loading=true on properties during initial refresh.

This commit is contained in:
Fabio Manganiello 2023-12-30 04:42:06 +01:00
parent 5bec01a389
commit 57737b1b72
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -235,7 +235,7 @@ export default {
delete this.selector.selectedGroups[group.name] delete this.selector.selectedGroups[group.name]
}, },
async refresh(group) { async refresh(group, setLoading=true) {
const entities = (group ? group.entities : this.entities) || {} const entities = (group ? group.entities : this.entities) || {}
const args = {} const args = {}
if (group) if (group)
@ -244,29 +244,30 @@ export default {
return obj return obj
}, {}) }, {})
this.loadingEntities = Object.values(entities).reduce((obj, entity) => { if (setLoading)
if (this._shouldSkipLoading(entity)) 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 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) this.request('entities.scan', args)
}, },
@ -428,7 +429,7 @@ export default {
const hasCachedEntities = this.loadCachedEntities() const hasCachedEntities = this.loadCachedEntities()
await this.sync(!hasCachedEntities) await this.sync(!hasCachedEntities)
await this.refresh() await this.refresh(null, !hasCachedEntities)
setInterval(() => this.refreshEntitiesCache(), 10000) setInterval(() => this.refreshEntitiesCache(), 10000)
}, },