@@ -878,16 +878,14 @@ converse.plugins.add('converse-muc', {
878
878
* @param { HTMLElement } form - The configuration form DOM element.
879
879
* If no form is provided, the default configuration
880
880
* values will be used.
881
- * @returns { promise }
881
+ * @returns { Promise<XMLElement> }
882
882
* Returns a promise which resolves once the XMPP server
883
883
* has return a response IQ.
884
884
*/
885
885
saveConfiguration ( form ) {
886
- return new Promise ( ( resolve , reject ) => {
887
- const inputs = form ? sizzle ( ':input:not([type=button]):not([type=submit])' , form ) : [ ] ,
888
- configArray = _ . map ( inputs , u . webForm2xForm ) ;
889
- this . sendConfiguration ( configArray , resolve , reject ) ;
890
- } ) ;
886
+ const inputs = form ? sizzle ( ':input:not([type=button]):not([type=submit])' , form ) : [ ] ,
887
+ configArray = _ . map ( inputs , u . webForm2xForm ) ;
888
+ return this . sendConfiguration ( configArray ) ;
891
889
} ,
892
890
893
891
/**
@@ -926,54 +924,48 @@ converse.plugins.add('converse-muc', {
926
924
* 'roomconfig' data.
927
925
* @private
928
926
* @method _converse.ChatRoom#autoConfigureChatRoom
929
- * @returns { promise }
927
+ * @returns { Promise<XMLElement> }
930
928
* Returns a promise which resolves once a response IQ has
931
929
* been received.
932
930
*/
933
- autoConfigureChatRoom ( ) {
934
- return new Promise ( async ( resolve , reject ) => { /* eslint-disable-line no-async-promise-executor */
935
- const stanza = await this . fetchRoomConfiguration ( ) ;
936
- const fields = sizzle ( 'field' , stanza ) ;
937
- const configArray = fields . map ( f => this . addFieldValue ( f ) )
938
- if ( configArray . length ) {
939
- this . sendConfiguration ( configArray , resolve , reject ) ;
940
- }
941
- } ) ;
931
+ async autoConfigureChatRoom ( ) {
932
+ const stanza = await this . fetchRoomConfiguration ( ) ;
933
+ const fields = sizzle ( 'field' , stanza ) ;
934
+ const configArray = fields . map ( f => this . addFieldValue ( f ) )
935
+ if ( configArray . length ) {
936
+ return this . sendConfiguration ( configArray ) ;
937
+ }
942
938
} ,
943
939
940
+ /**
941
+ * Send an IQ stanza to fetch the groupchat configuration data.
942
+ * Returns a promise which resolves once the response IQ
943
+ * has been received.
944
+ * @private
945
+ * @method _converse.ChatRoom#fetchRoomConfiguration
946
+ * @returns { Promise<XMLElement> }
947
+ */
944
948
fetchRoomConfiguration ( ) {
945
- /* Send an IQ stanza to fetch the groupchat configuration data.
946
- * Returns a promise which resolves once the response IQ
947
- * has been received.
948
- */
949
949
return _converse . api . sendIQ (
950
950
$iq ( { 'to' : this . get ( 'jid' ) , 'type' : "get" } )
951
951
. c ( "query" , { xmlns : Strophe . NS . MUC_OWNER } )
952
952
) ;
953
953
} ,
954
954
955
955
/**
956
- * Send an IQ stanza with the groupchat configuration.
956
+ * Sends an IQ stanza with the groupchat configuration.
957
957
* @private
958
958
* @method _converse.ChatRoom#sendConfiguration
959
959
* @param { Array } config - The groupchat configuration
960
- * @param { Function } callback - Callback upon succesful IQ response
961
- * The first parameter passed in is IQ containing the
962
- * groupchat configuration.
963
- * The second is the response IQ from the server.
964
- * @param { Function } errback - Callback upon error IQ response
965
- * The first parameter passed in is IQ containing the
966
- * groupchat configuration.
967
- * The second is the response IQ from the server.
960
+ * @returns { Promise<XMLElement> } - A promise which resolves with
961
+ * the `result` stanza received from the XMPP server.
968
962
*/
969
- sendConfiguration ( config = [ ] , callback , errback ) {
963
+ sendConfiguration ( config = [ ] ) {
970
964
const iq = $iq ( { to : this . get ( 'jid' ) , type : "set" } )
971
965
. c ( "query" , { xmlns : Strophe . NS . MUC_OWNER } )
972
966
. c ( "x" , { xmlns : Strophe . NS . XFORM , type : "submit" } ) ;
973
967
config . forEach ( node => iq . cnode ( node ) . up ( ) ) ;
974
- callback = _ . isUndefined ( callback ) ? _ . noop : _ . partial ( callback , iq . nodeTree ) ;
975
- errback = _ . isUndefined ( errback ) ? _ . noop : _ . partial ( errback , iq . nodeTree ) ;
976
- return _converse . api . sendIQ ( iq ) . then ( callback ) . catch ( errback ) ;
968
+ return _converse . api . sendIQ ( iq ) ;
977
969
} ,
978
970
979
971
/**
@@ -1138,7 +1130,7 @@ converse.plugins.add('converse-muc', {
1138
1130
* a string if only one affiliation.
1139
1131
* @param { function } deltaFunc - The function to compute the delta
1140
1132
* between old and new member lists.
1141
- * @returns { promise }
1133
+ * @returns { Promise }
1142
1134
* A promise which is resolved once the list has been
1143
1135
* updated or once it's been established there's no need
1144
1136
* to update the list.
@@ -1156,7 +1148,7 @@ converse.plugins.add('converse-muc', {
1156
1148
* nickname and if found, persist that to the model state.
1157
1149
* @private
1158
1150
* @method _converse.ChatRoom#getAndPersistNickname
1159
- * @returns { promise } A promise which resolves with the nickname
1151
+ * @returns { Promise<string> } A promise which resolves with the nickname
1160
1152
*/
1161
1153
async getAndPersistNickname ( nick ) {
1162
1154
nick = nick ||
@@ -1176,7 +1168,7 @@ converse.plugins.add('converse-muc', {
1176
1168
* If so, we'll use that, otherwise we render the nickname form.
1177
1169
* @private
1178
1170
* @method _converse.ChatRoom#getReservedNick
1179
- * @returns { promise } A promise which resolves with the reserved nick or null
1171
+ * @returns { Promise<string> } A promise which resolves with the reserved nick or null
1180
1172
*/
1181
1173
async getReservedNick ( ) {
1182
1174
let iq ;
0 commit comments