Skip to content

Commit 573f5e9

Browse files
authored
Fix issue where new properties were unusable. (#2435)
1 parent ab8bb0d commit 573f5e9

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

static/js/models/gateway-model.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ class GatewayModel extends Model {
5050
}
5151

5252
setThing(thingId, description) {
53-
if (!this.thingModels.has(thingId)) {
53+
if (this.thingModels.has(thingId)) {
54+
const thingModel = this.thingModels.get(thingId);
55+
thingModel.updateFromDescription(description);
56+
} else {
5457
const thingModel = new ThingModel(description, this.ws);
5558
thingModel.subscribe(
5659
Constants.DELETE_THING,

static/js/models/thing-model.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,22 @@ const Constants = require('../constants');
1515
class ThingModel extends Model {
1616
constructor(description, ws) {
1717
super();
18-
this.title = description.title;
1918
this.properties = {};
2019
this.events = [];
2120
this.connected = false;
2221

22+
this.updateFromDescription(description);
23+
24+
this.initWebSocket(ws);
25+
26+
this.updateEvents();
27+
28+
return this;
29+
}
30+
31+
updateFromDescription(description) {
32+
this.title = description.title;
33+
2334
// Parse base URL of Thing
2435
if (description.href) {
2536
this.href = new URL(description.href, App.ORIGIN);
@@ -57,12 +68,6 @@ class ThingModel extends Model {
5768
this.eventDescriptions[eventName] = event;
5869
}
5970
}
60-
61-
this.initWebSocket(ws);
62-
63-
this.updateEvents();
64-
65-
return this;
6671
}
6772

6873
/**

0 commit comments

Comments
 (0)