From fd9e41a9170e938b87970fb68c66fe80aa6bcb5b Mon Sep 17 00:00:00 2001 From: JC Brand Date: Fri, 12 Aug 2022 10:27:09 +0200 Subject: [PATCH] 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`. --- src/headless/plugins/disco/entity.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/headless/plugins/disco/entity.js b/src/headless/plugins/disco/entity.js index c615aef49..8cd5594b5 100644 --- a/src/headless/plugins/disco/entity.js +++ b/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); } }); },