diff --git a/docs/CHANGES.md b/docs/CHANGES.md index 327f376f6..f94fd5462 100755 --- a/docs/CHANGES.md +++ b/docs/CHANGES.md @@ -16,6 +16,8 @@ * Templates are no longer stored as attributes on the `_converse` object. 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] - 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. diff --git a/src/converse-bookmarks.js b/src/converse-bookmarks.js index 531a3b3c9..e68b3f615 100644 --- a/src/converse-bookmarks.js +++ b/src/converse-bookmarks.js @@ -158,7 +158,7 @@ this.$el.find('div.chatroom-form-container').hide( function () { $(this).remove(); - that.$('.chatroom-body').children().removeClass('hidden'); + that.renderAfterTransition(); }); }, diff --git a/src/converse-muc.js b/src/converse-muc.js index 554691a44..6635bf459 100755 --- a/src/converse-muc.js +++ b/src/converse-muc.js @@ -84,8 +84,9 @@ var ROOMSTATUS = { CONNECTED: 0, CONNECTING: 1, - DISCONNECTED: 2, - ENTERED: 3 + NICKNAME_REQUIRED: 2, + DISCONNECTED: 3, + ENTERED: 4 }; converse.plugins.add('converse-muc', { @@ -1250,8 +1251,7 @@ this.$el.find('div.chatroom-form-container').hide( function () { $(this).remove(); - that.$el.find('.chat-area').removeClass('hidden'); - that.$el.find('.occupants').removeClass('hidden'); + that.renderAfterTransition(); }); return deferred.promise(); }, @@ -1305,8 +1305,7 @@ this.$el.find('div.chatroom-form-container').hide( function () { $(this).remove(); - that.$el.find('.chat-area').removeClass('hidden'); - that.$el.find('.occupants').removeClass('hidden'); + that.renderAfterTransition(); }); }, @@ -1535,6 +1534,7 @@ label_join: __('Enter room'), validation_message: message })); + this.model.save('connection_status', ROOMSTATUS.NICKNAME_REQUIRED); this.$('.chatroom-form').on('submit', this.submitNickname.bind(this)); }, @@ -1768,20 +1768,29 @@ this.$el.find('.chatroom-body').prepend(''); }, + 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 () { /* Check if the spinner is being shown and if so, hide it. * Also make sure then that the chat area and occupants * list are both visible. */ - var that = this; - var $spinner = this.$el.find('.spinner'); - if ($spinner.length) { - $spinner.hide(function () { - $(this).remove(); - that.$el.find('.chat-area').removeClass('hidden'); - that.$el.find('.occupants').removeClass('hidden'); - that.scrollDown(); - }); + var spinner = this.el.querySelector('.spinner'); + if (!_.isNull(spinner)) { + spinner.parentNode.removeChild(spinner); + this.renderAfterTransition(); } return this; },