Commit 5954cd8f authored by JC Brand's avatar JC Brand

Avoid duplicating entities

parent 6126781d
...@@ -66487,10 +66487,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -66487,10 +66487,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
const jid = item.getAttribute('jid'); const jid = item.getAttribute('jid');
if (_.isUndefined(this.items.get(jid))) { if (_.isUndefined(this.items.get(jid))) {
const entity = _converse.disco_entities.get(jid);
if (entity) {
this.items.add(entity);
} else {
this.items.create({ this.items.create({
'jid': jid 'jid': jid
}); });
} }
}
}); });
}, },
...@@ -66941,9 +66947,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -66941,9 +66947,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
* (String) entity_jid - The JID of the entity which might have the identity * (String) entity_jid - The JID of the entity which might have the identity
*/ */
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
_converse.api.waitUntil('discoInitialized').then(() => {
_converse.api.disco.entities.get(entity_jid, true).then(entity => resolve(entity.getIdentity(category, type))); _converse.api.disco.entities.get(entity_jid, true).then(entity => resolve(entity.getIdentity(category, type)));
});
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)); }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
} }
...@@ -14,7 +14,11 @@ ...@@ -14,7 +14,11 @@
describe("Whenever converse.js queries a server for its features", function () { describe("Whenever converse.js queries a server for its features", function () {
it("stores the features it receives", mock.initConverseWithAsync(function (done, _converse) { it("stores the features it receives",
mock.initConverseWithPromises(
null, ['discoInitialized'], {},
function (done, _converse) {
var IQ_stanzas = _converse.connection.IQ_stanzas; var IQ_stanzas = _converse.connection.IQ_stanzas;
var IQ_ids = _converse.connection.IQ_ids; var IQ_ids = _converse.connection.IQ_ids;
test_utils.waitUntil(function () { test_utils.waitUntil(function () {
......
...@@ -138,8 +138,13 @@ ...@@ -138,8 +138,13 @@
} }
const jid = item.getAttribute('jid'); const jid = item.getAttribute('jid');
if (_.isUndefined(this.items.get(jid))) { if (_.isUndefined(this.items.get(jid))) {
const entity = _converse.disco_entities.get(jid);
if (entity) {
this.items.add(entity);
} else {
this.items.create({'jid': jid}); this.items.create({'jid': jid});
} }
}
}); });
}, },
...@@ -514,10 +519,8 @@ ...@@ -514,10 +519,8 @@
* (String) entity_jid - The JID of the entity which might have the identity * (String) entity_jid - The JID of the entity which might have the identity
*/ */
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
_converse.api.waitUntil('discoInitialized').then(() => {
_converse.api.disco.entities.get(entity_jid, true) _converse.api.disco.entities.get(entity_jid, true)
.then((entity) => resolve(entity.getIdentity(category, type))); .then((entity) => resolve(entity.getIdentity(category, type)));
})
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)); }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment