浏览代码

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 年之前
父节点
当前提交
fd9e41a917
共有 1 个文件被更改,包括 2 次插入4 次删除
  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);
             }
         });
     },