Skip to content

Commit

Permalink
Fix textual things not updating on the first change (#4219)
Browse files Browse the repository at this point in the history
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
  • Loading branch information
jimtng authored May 6, 2024
1 parent d083a53 commit 456d5d3
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}
Expand Down

0 comments on commit 456d5d3

Please sign in to comment.