Commit 69e20682 authored by JC Brand's avatar JC Brand

converse-muc: Remove unused promises

Now that we cache disco info and not the room configuration.
parent 81879bc0
...@@ -875,7 +875,6 @@ ...@@ -875,7 +875,6 @@
* (XMLElement) stanza: The IQ stanza containing the room config. * (XMLElement) stanza: The IQ stanza containing the room config.
*/ */
var that = this, var that = this,
deferred = new $.Deferred(),
$body = this.$('.chatroom-body'); $body = this.$('.chatroom-body');
$body.children().addClass('hidden'); $body.children().addClass('hidden');
$body.append(converse.templates.chatroom_form()); $body.append(converse.templates.chatroom_form());
...@@ -901,15 +900,11 @@ ...@@ -901,15 +900,11 @@
$fieldset.find('input[type=button]').on('click', function (ev) { $fieldset.find('input[type=button]').on('click', function (ev) {
ev.preventDefault(); ev.preventDefault();
that.cancelConfiguration(); that.cancelConfiguration();
deferred.reject(stanza);
}); });
$form.on('submit', function (ev) { $form.on('submit', function (ev) {
ev.preventDefault(); ev.preventDefault();
that.saveConfiguration(ev.target) that.saveConfiguration(ev.target);
.done(deferred.resolve)
.fail(_.partial(deferred, stanza));
}); });
return deferred.promise();
}, },
sendConfiguration: function(config, onSuccess, onError) { sendConfiguration: function(config, onSuccess, onError) {
...@@ -945,25 +940,19 @@ ...@@ -945,25 +940,19 @@
* Parameters: * Parameters:
* (HTMLElement) form: The configuration form DOM element. * (HTMLElement) form: The configuration form DOM element.
*/ */
var deferred = new $.Deferred();
var that = this; var that = this;
var $inputs = $(form).find(':input:not([type=button]):not([type=submit])'), var $inputs = $(form).find(':input:not([type=button]):not([type=submit])'),
configArray = []; configArray = [];
$inputs.each(function () { $inputs.each(function () {
configArray.push(utils.webForm2xForm(this)); configArray.push(utils.webForm2xForm(this));
}); });
this.sendConfiguration( this.sendConfiguration(configArray);
configArray,
deferred.resolve,
deferred.reject
);
this.$el.find('div.chatroom-form-container').hide( this.$el.find('div.chatroom-form-container').hide(
function () { function () {
$(this).remove(); $(this).remove();
that.$el.find('.chat-area').removeClass('hidden'); that.$el.find('.chat-area').removeClass('hidden');
that.$el.find('.occupants').removeClass('hidden'); that.$el.find('.occupants').removeClass('hidden');
}); });
return deferred.promise();
}, },
autoConfigureChatRoom: function (stanza) { autoConfigureChatRoom: function (stanza) {
...@@ -977,7 +966,6 @@ ...@@ -977,7 +966,6 @@
* (XMLElement) stanza: IQ stanza from the server, * (XMLElement) stanza: IQ stanza from the server,
* containing the configuration. * containing the configuration.
*/ */
var deferred = new $.Deferred();
var that = this, configArray = [], var that = this, configArray = [],
$fields = $(stanza).find('field'), $fields = $(stanza).find('field'),
count = $fields.length, count = $fields.length,
...@@ -1003,14 +991,9 @@ ...@@ -1003,14 +991,9 @@
} }
configArray.push(this); configArray.push(this);
if (!--count) { if (!--count) {
that.sendConfiguration( that.sendConfiguration(configArray);
configArray,
deferred.resolve,
_.partial(deferred.reject, stanza)
);
} }
}); });
return deferred.promise();
}, },
cancelConfiguration: function () { cancelConfiguration: function () {
...@@ -1664,6 +1647,8 @@ ...@@ -1664,6 +1647,8 @@
'label_occupants': __('Occupants') 'label_occupants': __('Occupants')
}) })
); );
// TODO: don't allow the widget if members-only room and
// not room owner.
if (converse.allow_muc_invitations) { if (converse.allow_muc_invitations) {
return this.initInviteWidget(); return this.initInviteWidget();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment