Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.

Commit cbe10ab

Browse files
updated browser version
1 parent acafc70 commit cbe10ab

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

browser/wapp-api.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -452,24 +452,22 @@ class Collection extends EventEmitter {
452452
isArray = false;
453453
}
454454
data.forEach((element, index) => {
455-
let id, lookFor;
455+
let obj, lookFor;
456456
if(element.constructor === Object){
457457
if(this.models.includes(element)){
458458
results.push(element);
459459
return;
460460
}
461-
id = element.meta && element.meta.id
461+
lookFor = element;
462+
obj = lookFor;
462463
} else if(element.constructor === String){
463-
id = element;
464+
lookFor = { meta: { id: element }};
465+
obj = lookFor;
464466
} else if(element.constructor === Array){
465467
return;
466468
} else {
467-
id = element.get("meta.id");
468-
}
469-
if(id){
470-
lookFor = { meta: { id: id }};
471-
} else {
472-
lookFor = element
469+
lookFor = { meta: { id: element.get("meta.id") }};
470+
obj = element;
473471
}
474472
let found = this.find(lookFor, options);
475473
if (found) {
@@ -480,7 +478,7 @@ class Collection extends EventEmitter {
480478
}
481479
results.push(found);
482480
} else if (this[_class] && !(element instanceof Generic)) {
483-
let newInstance = new this[_class](element, this[_requestInstance]);
481+
let newInstance = new this[_class](obj, this[_requestInstance]);
484482
newInstance[_collections].push(this);
485483
this._pushToModels(newInstance, options);
486484
results.push(newInstance);

0 commit comments

Comments
 (0)