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
1aceaa9c
Commit
1aceaa9c
authored
Aug 09, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid creating unnecesary promises
by returning existing promises and by using _converse.api.sendIQ
parent
daf470e3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
17 deletions
+13
-17
src/converse-muc.js
src/converse-muc.js
+13
-17
No files found.
src/converse-muc.js
View file @
1aceaa9c
...
@@ -471,13 +471,11 @@
...
@@ -471,13 +471,11 @@
* A promise which resolves once the list has been
* A promise which resolves once the list has been
* retrieved.
* retrieved.
*/
*/
return
new
Promise
((
resolve
,
reject
)
=>
{
affiliation
=
affiliation
||
'
member
'
;
affiliation
=
affiliation
||
'
member
'
;
const
iq
=
$iq
({
to
:
this
.
get
(
'
jid
'
),
type
:
"
get
"
})
const
iq
=
$iq
({
to
:
this
.
get
(
'
jid
'
),
type
:
"
get
"
})
.
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
MUC_ADMIN
})
.
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
MUC_ADMIN
})
.
c
(
"
item
"
,
{
'
affiliation
'
:
affiliation
});
.
c
(
"
item
"
,
{
'
affiliation
'
:
affiliation
});
_converse
.
connection
.
sendIQ
(
iq
,
resolve
,
reject
);
return
_converse
.
api
.
sendIQ
(
iq
);
});
},
},
setAffiliation
(
affiliation
,
members
)
{
setAffiliation
(
affiliation
,
members
)
{
...
@@ -678,16 +676,14 @@
...
@@ -678,16 +676,14 @@
if
(
_
.
isString
(
affiliations
))
{
if
(
_
.
isString
(
affiliations
))
{
affiliations
=
[
affiliations
];
affiliations
=
[
affiliations
];
}
}
return
new
Promise
((
resolve
,
reject
)
=>
{
const
promises
=
_
.
map
(
const
promises
=
_
.
map
(
affiliations
,
affiliations
,
_
.
partial
(
this
.
requestMemberList
.
bind
(
this
))
_
.
partial
(
this
.
requestMemberList
.
bind
(
this
))
);
);
Promise
.
all
(
promises
).
then
(
return
Promise
.
all
(
promises
).
then
(
_
.
flow
(
u
.
marshallAffiliationIQs
,
resolve
),
(
iq
)
=>
u
.
marshallAffiliationIQs
(
iq
),
_
.
flow
(
u
.
marshallAffiliationIQs
,
resolve
)
(
iq
)
=>
u
.
marshallAffiliationIQs
(
iq
)
);
);
});
},
},
updateMemberLists
(
members
,
affiliations
,
deltaFunc
)
{
updateMemberLists
(
members
,
affiliations
,
deltaFunc
)
{
...
...
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