Fix textual things not updating on the first change (#4219)

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
This commit is contained in:
jimtng
2024-05-06 09:24:04 +02:00
committed by GitHub
parent d083a5379c
commit 456d5d3dd0
@@ -605,8 +605,9 @@ class GenericThingProvider extends AbstractProviderLazyNullness<Thing> implement
if (!loadedXmlThingTypes.contains(factory.bundleName) || modelRepository == null) {
return
}
val things = thingsMap.get(modelName)
val oldThings = things.clone
val newThings = newArrayList()
val oldThings = thingsMap.put(modelName, newThings)
val model = modelRepository.getModel(modelName) as ThingModel
if (model !== null) {
@@ -619,10 +620,13 @@ class GenericThingProvider extends AbstractProviderLazyNullness<Thing> implement
val oldThing = oldThings.findFirst[it.UID == newThing.UID]
if (oldThing !== null) {
if (!ThingHelper.equals(oldThing, newThing)) {
things.remove(oldThing)
things.add(newThing)
logger.debug("Updating thing '{}' from model '{}'.", newThing.UID, modelName);
notifyListenersAboutUpdatedElement(oldThing, newThing)
}
} else {
things.add(newThing)
logger.debug("Adding thing '{}' from model '{}'.", newThing.UID, modelName);
newThing.notifyListenersAboutAddedElement
}