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
802f2b24
Commit
802f2b24
authored
Jul 11, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
converse-muc: Update `sendConfiguration` to not take callbacks
parent
d95a7987
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
36 deletions
+28
-36
src/headless/converse-muc.js
src/headless/converse-muc.js
+28
-36
No files found.
src/headless/converse-muc.js
View file @
802f2b24
...
@@ -878,16 +878,14 @@ converse.plugins.add('converse-muc', {
...
@@ -878,16 +878,14 @@ converse.plugins.add('converse-muc', {
* @param { HTMLElement } form - The configuration form DOM element.
* @param { HTMLElement } form - The configuration form DOM element.
* If no form is provided, the default configuration
* If no form is provided, the default configuration
* values will be used.
* values will be used.
* @returns {
promise
}
* @returns {
Promise<XMLElement>
}
* Returns a promise which resolves once the XMPP server
* Returns a promise which resolves once the XMPP server
* has return a response IQ.
* has return a response IQ.
*/
*/
saveConfiguration
(
form
)
{
saveConfiguration
(
form
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
inputs
=
form
?
sizzle
(
'
:input:not([type=button]):not([type=submit])
'
,
form
)
:
[],
const
inputs
=
form
?
sizzle
(
'
:input:not([type=button]):not([type=submit])
'
,
form
)
:
[],
configArray
=
_
.
map
(
inputs
,
u
.
webForm2xForm
);
configArray
=
_
.
map
(
inputs
,
u
.
webForm2xForm
);
this
.
sendConfiguration
(
configArray
,
resolve
,
reject
);
return
this
.
sendConfiguration
(
configArray
);
});
},
},
/**
/**
...
@@ -926,26 +924,28 @@ converse.plugins.add('converse-muc', {
...
@@ -926,26 +924,28 @@ converse.plugins.add('converse-muc', {
* 'roomconfig' data.
* 'roomconfig' data.
* @private
* @private
* @method _converse.ChatRoom#autoConfigureChatRoom
* @method _converse.ChatRoom#autoConfigureChatRoom
* @returns {
promise
}
* @returns {
Promise<XMLElement>
}
* Returns a promise which resolves once a response IQ has
* Returns a promise which resolves once a response IQ has
* been received.
* been received.
*/
*/
autoConfigureChatRoom
()
{
async
autoConfigureChatRoom
()
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
/* eslint-disable-line no-async-promise-executor */
const
stanza
=
await
this
.
fetchRoomConfiguration
();
const
stanza
=
await
this
.
fetchRoomConfiguration
();
const
fields
=
sizzle
(
'
field
'
,
stanza
);
const
fields
=
sizzle
(
'
field
'
,
stanza
);
const
configArray
=
fields
.
map
(
f
=>
this
.
addFieldValue
(
f
))
const
configArray
=
fields
.
map
(
f
=>
this
.
addFieldValue
(
f
))
if
(
configArray
.
length
)
{
if
(
configArray
.
length
)
{
this
.
sendConfiguration
(
configArray
,
resolve
,
reject
);
return
this
.
sendConfiguration
(
configArray
);
}
}
});
},
},
fetchRoomConfiguration
()
{
/**
/
* Send an IQ stanza to fetch the groupchat configuration data.
* Send an IQ stanza to fetch the groupchat configuration data.
* Returns a promise which resolves once the response IQ
* Returns a promise which resolves once the response IQ
* has been received.
* has been received.
* @private
* @method _converse.ChatRoom#fetchRoomConfiguration
* @returns { Promise<XMLElement> }
*/
*/
fetchRoomConfiguration
()
{
return
_converse
.
api
.
sendIQ
(
return
_converse
.
api
.
sendIQ
(
$iq
({
'
to
'
:
this
.
get
(
'
jid
'
),
'
type
'
:
"
get
"
})
$iq
({
'
to
'
:
this
.
get
(
'
jid
'
),
'
type
'
:
"
get
"
})
.
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
MUC_OWNER
})
.
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
MUC_OWNER
})
...
@@ -953,27 +953,19 @@ converse.plugins.add('converse-muc', {
...
@@ -953,27 +953,19 @@ converse.plugins.add('converse-muc', {
},
},
/**
/**
* Send an IQ stanza with the groupchat configuration.
* Send
s
an IQ stanza with the groupchat configuration.
* @private
* @private
* @method _converse.ChatRoom#sendConfiguration
* @method _converse.ChatRoom#sendConfiguration
* @param { Array } config - The groupchat configuration
* @param { Array } config - The groupchat configuration
* @param { Function } callback - Callback upon succesful IQ response
* @returns { Promise<XMLElement> } - A promise which resolves with
* The first parameter passed in is IQ containing the
* the `result` stanza received from the XMPP server.
* groupchat configuration.
* The second is the response IQ from the server.
* @param { Function } errback - Callback upon error IQ response
* The first parameter passed in is IQ containing the
* groupchat configuration.
* The second is the response IQ from the server.
*/
*/
sendConfiguration
(
config
=
[]
,
callback
,
errback
)
{
sendConfiguration
(
config
=
[])
{
const
iq
=
$iq
({
to
:
this
.
get
(
'
jid
'
),
type
:
"
set
"
})
const
iq
=
$iq
({
to
:
this
.
get
(
'
jid
'
),
type
:
"
set
"
})
.
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
MUC_OWNER
})
.
c
(
"
query
"
,
{
xmlns
:
Strophe
.
NS
.
MUC_OWNER
})
.
c
(
"
x
"
,
{
xmlns
:
Strophe
.
NS
.
XFORM
,
type
:
"
submit
"
});
.
c
(
"
x
"
,
{
xmlns
:
Strophe
.
NS
.
XFORM
,
type
:
"
submit
"
});
config
.
forEach
(
node
=>
iq
.
cnode
(
node
).
up
());
config
.
forEach
(
node
=>
iq
.
cnode
(
node
).
up
());
callback
=
_
.
isUndefined
(
callback
)
?
_
.
noop
:
_
.
partial
(
callback
,
iq
.
nodeTree
);
return
_converse
.
api
.
sendIQ
(
iq
);
errback
=
_
.
isUndefined
(
errback
)
?
_
.
noop
:
_
.
partial
(
errback
,
iq
.
nodeTree
);
return
_converse
.
api
.
sendIQ
(
iq
).
then
(
callback
).
catch
(
errback
);
},
},
/**
/**
...
@@ -1138,7 +1130,7 @@ converse.plugins.add('converse-muc', {
...
@@ -1138,7 +1130,7 @@ converse.plugins.add('converse-muc', {
* a string if only one affiliation.
* a string if only one affiliation.
* @param { function } deltaFunc - The function to compute the delta
* @param { function } deltaFunc - The function to compute the delta
* between old and new member lists.
* between old and new member lists.
* @returns {
p
romise }
* @returns {
P
romise }
* A promise which is resolved once the list has been
* A promise which is resolved once the list has been
* updated or once it's been established there's no need
* updated or once it's been established there's no need
* to update the list.
* to update the list.
...
@@ -1156,7 +1148,7 @@ converse.plugins.add('converse-muc', {
...
@@ -1156,7 +1148,7 @@ converse.plugins.add('converse-muc', {
* nickname and if found, persist that to the model state.
* nickname and if found, persist that to the model state.
* @private
* @private
* @method _converse.ChatRoom#getAndPersistNickname
* @method _converse.ChatRoom#getAndPersistNickname
* @returns {
promise
} A promise which resolves with the nickname
* @returns {
Promise<string>
} A promise which resolves with the nickname
*/
*/
async
getAndPersistNickname
(
nick
)
{
async
getAndPersistNickname
(
nick
)
{
nick
=
nick
||
nick
=
nick
||
...
@@ -1176,7 +1168,7 @@ converse.plugins.add('converse-muc', {
...
@@ -1176,7 +1168,7 @@ converse.plugins.add('converse-muc', {
* If so, we'll use that, otherwise we render the nickname form.
* If so, we'll use that, otherwise we render the nickname form.
* @private
* @private
* @method _converse.ChatRoom#getReservedNick
* @method _converse.ChatRoom#getReservedNick
* @returns {
promise
} A promise which resolves with the reserved nick or null
* @returns {
Promise<string>
} A promise which resolves with the reserved nick or null
*/
*/
async
getReservedNick
()
{
async
getReservedNick
()
{
let
iq
;
let
iq
;
...
...
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