fix: entity.toNetwork
This commit is contained in:
parent
b3baaedde9
commit
f308ebb469
|
@ -274,11 +274,11 @@ export class Entity extends decorate(Resource) {
|
|||
return pristine;
|
||||
}
|
||||
|
||||
mergeDiff() {
|
||||
mergeDiff(json) {
|
||||
if (!this.uri) {
|
||||
return this.toJSON();
|
||||
return json;
|
||||
}
|
||||
return mergeDiff(this._json, this.toJSON());
|
||||
return mergeDiff(this._json, json);
|
||||
}
|
||||
|
||||
packets(informed) {
|
||||
|
@ -391,8 +391,16 @@ export class Entity extends decorate(Resource) {
|
|||
}
|
||||
}
|
||||
|
||||
toNetwork() {
|
||||
return this.mergeDiff();
|
||||
toNetwork(informed) {
|
||||
const json = {
|
||||
...super.toJSON(),
|
||||
instanceUuid: this.instanceUuid,
|
||||
traits: {},
|
||||
};
|
||||
for (const type in this._traits) {
|
||||
json.traits[type] = this._traits[type].toNetwork(informed);
|
||||
}
|
||||
return this.mergeDiff(json);
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
|
|
|
@ -210,14 +210,15 @@ export class EntityList extends decorate(class {}) {
|
|||
// Mark as notified.
|
||||
this._informedEntities.set(informed, visibleEntities);
|
||||
return visibleEntities.map((entity) => {
|
||||
return entity.mergeDiff();
|
||||
return entity.toNetwork(informed);
|
||||
});
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
const json = [];
|
||||
for (let i = 0; i < this._flatEntities.length; i++) {
|
||||
json.push(this._flatEntities[i].mergeDiff());
|
||||
const entity = this._flatEntities[i];
|
||||
json.push(entity.mergeDiff(entity.toJSON()));
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user