Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

fix: external attribute change becomes user change (#1711) (#1722)

Ekhorne4095fca19a0
diff --git a/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts b/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts
index 00dd98df0..a940410c0 100644
--- a/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts
+++ b/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts
@@ -204,7 +204,15 @@ export class OrEditAssetPanel extends LitElement {
shouldUpdate(changedProperties: PropertyValues): boolean {
if (changedProperties.has("asset")) {
- this.changedAttributes = [];
+ const oldAsset = changedProperties.get("asset") as Asset;
+ if (this.asset.attributes && oldAsset?.attributes && this.asset.id === oldAsset.id) {
+ // Handles external attribute changes post saving phase.
+ this.changedAttributes = Object.values(oldAsset.attributes)
+ .filter(({ name, timestamp: oldTimestamp }) => oldTimestamp !== this.asset.attributes?.[name!].timestamp)
+ .map(({ name }) => name!);
+ } else {
+ this.changedAttributes = [];
+ }
}
return super.shouldUpdate(changedProperties);
}