Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
5954cd8f
Commit
5954cd8f
authored
Jun 07, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid duplicating entities
parent
6126781d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
12 deletions
+23
-12
dist/converse.js
dist/converse.js
+10
-6
spec/disco.js
spec/disco.js
+5
-1
src/converse-disco.js
src/converse-disco.js
+8
-5
No files found.
dist/converse.js
View file @
5954cd8f
...
...
@@ -66487,10 +66487,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
const jid = item.getAttribute('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
});
}
}
});
},
...
...
@@ -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
*/
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)));
});
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
}
spec/disco.js
View file @
5954cd8f
...
...
@@ -14,7 +14,11 @@
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_ids
=
_converse
.
connection
.
IQ_ids
;
test_utils
.
waitUntil
(
function
()
{
...
...
src/converse-disco.js
View file @
5954cd8f
...
...
@@ -138,8 +138,13 @@
}
const
jid
=
item
.
getAttribute
(
'
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
});
}
}
});
},
...
...
@@ -514,10 +519,8 @@
* (String) entity_jid - The JID of the entity which might have the identity
*/
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
)));
})
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment