Browse Source

Fix failing test.

The fix from @joudinet was to call `this.items.create` on `DiscoEntity`,
however we still need to pass in the same `entity` model as before so that both
collections (`this.items` and `_converse.disco_entities`) have a
referene to the same model.

That way, when attributes like `.identities` are added on the entity,
it's available from both `this.items` and `_converse.disco_entities`.
JC Brand 2 years ago
parent
commit
fd9e41a917
1 changed files with 2 additions and 4 deletions
  1. 2 4
      src/headless/plugins/disco/entity.js

+ 2 - 4
src/headless/plugins/disco/entity.js

@@ -142,11 +142,9 @@ const DiscoEntity = Model.extend({
             }
             const jid = item.getAttribute('jid');
             if (this.items.get(jid) === undefined) {
-                const name = item.getAttribute('name');
                 const entities = _converse.disco_entities;
-                if (!entities.get(jid))
-                    entities.create({ jid, name });
-                this.items.create({ jid, name });
+                const entity = entities.get(jid) || entities.create({ jid, name: item.getAttribute('name') });
+                this.items.create(entity);
             }
         });
     },