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
cce27fac
Commit
cce27fac
authored
Sep 02, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid unnecessary promise wrapping
parent
16deecd4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
24 deletions
+16
-24
src/converse-disco.js
src/converse-disco.js
+16
-24
No files found.
src/converse-disco.js
View file @
cce27fac
...
...
@@ -473,7 +473,7 @@
}
},
'
supports
'
(
feature
,
entity_
jid
)
{
'
supports
'
(
feature
,
jid
)
{
/* Returns a Promise which resolves with a list containing
* _converse.Entity instances representing the entity
* itself or those items associated with the entity if
...
...
@@ -484,30 +484,25 @@
* supported. In the XML stanza, this is the `var`
* attribute of the `<feature>` element. For
* example: 'http://jabber.org/protocol/muc'
* (String)
entity_
jid - The JID of the entity
* (String) jid - The JID of the entity
* (and its associated items) which should be queried
*/
if
(
_
.
isNil
(
entity_
jid
))
{
if
(
_
.
isNil
(
jid
))
{
throw
new
TypeError
(
'
disco.supports: You need to provide an entity JID
'
);
}
return
new
Promise
((
resolve
,
reject
)
=>
{
return
_converse
.
api
.
waitUntil
(
'
discoInitialized
'
).
then
(()
=>
{
_converse
.
api
.
disco
.
entities
.
get
(
entity_jid
,
true
).
then
((
entity
)
=>
{
entity
.
waitUntilFeaturesDiscovered
.
then
(()
=>
{
return
_converse
.
api
.
waitUntil
(
'
discoInitialized
'
)
.
then
(()
=>
_converse
.
api
.
disco
.
entities
.
get
(
jid
,
true
))
.
then
(
entity
=>
entity
.
waitUntilFeaturesDiscovered
)
.
then
(
entity
=>
{
const
promises
=
_
.
concat
(
entity
.
items
.
map
((
item
)
=>
item
.
hasFeature
(
feature
)),
entity
.
items
.
map
(
item
=>
item
.
hasFeature
(
feature
)),
entity
.
hasFeature
(
feature
)
);
Promise
.
all
(
promises
).
then
((
result
)
=>
{
resolve
(
f
.
filter
(
f
.
isObject
,
result
));
}).
catch
(
reject
);
}).
catch
(
reject
);
}).
catch
(
reject
);
}).
catch
(
reject
);
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
return
Promise
.
all
(
promises
);
}).
then
(
result
=>
f
.
filter
(
f
.
isObject
,
result
));
},
'
getIdentity
'
(
category
,
type
,
entity_
jid
)
{
'
getIdentity
'
(
category
,
type
,
jid
)
{
/* Returns a Promise which resolves with a map indicating
* whether an identity with a given type is provided by
* the entity.
...
...
@@ -521,12 +516,9 @@
* In the XML stanza, this is the `type`
* attribute of the `<identity>` element.
* For example: 'pep'
* (String)
entity_
jid - The JID of the entity which might have the identity
* (String) jid - The JID of the entity which might have the identity
*/
return
new
Promise
((
resolve
,
reject
)
=>
{
_converse
.
api
.
disco
.
entities
.
get
(
entity_jid
,
true
)
.
then
((
entity
)
=>
resolve
(
entity
.
getIdentity
(
category
,
type
)));
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
return
_converse
.
api
.
disco
.
entities
.
get
(
jid
,
true
).
then
(
e
=>
e
.
getIdentity
(
category
,
type
));
}
}
});
...
...
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