After bookmarking a room for which a nickname is required, return to the nickname form.
This commit is contained in:
JC Brand 2017-03-02 23:28:22 +01:00
parent a5c0d5c451
commit 62c8177142
3 changed files with 27 additions and 16 deletions

View File

@ -16,6 +16,8 @@
* Templates are no longer stored as attributes on the `_converse` object. * Templates are no longer stored as attributes on the `_converse` object.
If you need a particular template, use `require` to load it. If you need a particular template, use `require` to load it.
- Bugfix. After bookmarking a room for which a nickname is required, return to
the nickname form. [jcbrand]
- Show the chat states of room occupants. [jcbrand] - Show the chat states of room occupants. [jcbrand]
- The no-jQuery build has been renamed from `converse.nojquery.js` to - The no-jQuery build has been renamed from `converse.nojquery.js` to
`converse-no-jquery.js` to fit the convention used for other build names. `converse-no-jquery.js` to fit the convention used for other build names.

View File

@ -158,7 +158,7 @@
this.$el.find('div.chatroom-form-container').hide( this.$el.find('div.chatroom-form-container').hide(
function () { function () {
$(this).remove(); $(this).remove();
that.$('.chatroom-body').children().removeClass('hidden'); that.renderAfterTransition();
}); });
}, },

View File

@ -84,8 +84,9 @@
var ROOMSTATUS = { var ROOMSTATUS = {
CONNECTED: 0, CONNECTED: 0,
CONNECTING: 1, CONNECTING: 1,
DISCONNECTED: 2, NICKNAME_REQUIRED: 2,
ENTERED: 3 DISCONNECTED: 3,
ENTERED: 4
}; };
converse.plugins.add('converse-muc', { converse.plugins.add('converse-muc', {
@ -1250,8 +1251,7 @@
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.renderAfterTransition();
that.$el.find('.occupants').removeClass('hidden');
}); });
return deferred.promise(); return deferred.promise();
}, },
@ -1305,8 +1305,7 @@
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.renderAfterTransition();
that.$el.find('.occupants').removeClass('hidden');
}); });
}, },
@ -1535,6 +1534,7 @@
label_join: __('Enter room'), label_join: __('Enter room'),
validation_message: message validation_message: message
})); }));
this.model.save('connection_status', ROOMSTATUS.NICKNAME_REQUIRED);
this.$('.chatroom-form').on('submit', this.submitNickname.bind(this)); this.$('.chatroom-form').on('submit', this.submitNickname.bind(this));
}, },
@ -1768,20 +1768,29 @@
this.$el.find('.chatroom-body').prepend('<span class="spinner centered"/>'); this.$el.find('.chatroom-body').prepend('<span class="spinner centered"/>');
}, },
renderAfterTransition: function () {
/* Rerender the room after some kind of transition. For
* example after the spinner has been removed or after a
* form has been submitted and removed.
*/
if (this.model.get('connection_status') == ROOMSTATUS.NICKNAME_REQUIRED) {
this.renderNicknameForm();
} else {
this.$el.find('.chat-area').removeClass('hidden');
this.$el.find('.occupants').removeClass('hidden');
this.scrollDown();
}
},
hideSpinner: function () { hideSpinner: function () {
/* Check if the spinner is being shown and if so, hide it. /* Check if the spinner is being shown and if so, hide it.
* Also make sure then that the chat area and occupants * Also make sure then that the chat area and occupants
* list are both visible. * list are both visible.
*/ */
var that = this; var spinner = this.el.querySelector('.spinner');
var $spinner = this.$el.find('.spinner'); if (!_.isNull(spinner)) {
if ($spinner.length) { spinner.parentNode.removeChild(spinner);
$spinner.hide(function () { this.renderAfterTransition();
$(this).remove();
that.$el.find('.chat-area').removeClass('hidden');
that.$el.find('.occupants').removeClass('hidden');
that.scrollDown();
});
} }
return this; return this;
}, },