From 044907e4fa36796dc6c744b4b6a25fea02d6141d Mon Sep 17 00:00:00 2001 From: JC Brand Date: Wed, 14 Mar 2018 13:03:13 +0000 Subject: [PATCH] Looks like `focus` parameter was never used. --- spec/chatbox.js | 20 +++++++++++--------- src/converse-chatview.js | 13 +++++-------- src/converse-muc-views.js | 9 ++++----- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/spec/chatbox.js b/spec/chatbox.js index 4208df531..b011c0218 100644 --- a/spec/chatbox.js +++ b/spec/chatbox.js @@ -224,16 +224,19 @@ // visible, but no other chat boxes have been created. expect(_converse.chatboxes.length).toEqual(1); - spyOn(_converse.ChatBoxView.prototype, 'focus'); chatbox = test_utils.openChatBoxFor(_converse, contact_jid); - $el = $(_converse.rosterview.el).find('a.open-chat:contains("'+chatbox.get('fullname')+'")'); jid = $el.text().replace(/ /g,'.').toLowerCase() + '@localhost'; + + spyOn(_converse, 'emit'); $el[0].click(); - expect(_converse.chatboxes.length).toEqual(2); - var chatboxview = _converse.chatboxviews.get(contact_jid); - expect(chatboxview.focus).toHaveBeenCalled(); - done(); + test_utils.waitUntil(function () { + return _converse.emit.calls.count(); + }, 300).then(function () { + expect(_converse.chatboxes.length).toEqual(2); + expect(_converse.emit).toHaveBeenCalledWith('chatBoxFocused', jasmine.any(Object)); + done(); + }); })); @@ -280,9 +283,8 @@ test_utils.createContacts(_converse, 'current'); test_utils.openControlBox(); test_utils.waitUntil(function () { - return $(_converse.rosterview.el).find('.roster-group').length; - }, 300) - .then(function () { + return $(_converse.rosterview.el).find('.roster-group').length; + }, 300).then(function () { var chatbox = test_utils.openChatBoxes(_converse, 1)[0], controlview = _converse.chatboxviews.get('controlbox'), // The controlbox is currently open chatview = _converse.chatboxviews.get(chatbox.get('jid')); diff --git a/src/converse-chatview.js b/src/converse-chatview.js index 0e6386ba2..e1b679233 100644 --- a/src/converse-chatview.js +++ b/src/converse-chatview.js @@ -1083,7 +1083,7 @@ return this; }, - afterShown (focus) { + afterShown () { if (u.isPersistableModel(this.model)) { this.model.clearUnreadMsgCounter(); this.model.save(); @@ -1091,21 +1091,18 @@ this.setChatState(_converse.ACTIVE); this.renderEmojiPicker(); this.scrollDown(); - if (focus) { - this.focus(); - } }, - _show (focus) { + _show (f) { /* Inner show method that gets debounced */ if (u.isVisible(this.el)) { - if (focus) { this.focus(); } + this.focus(); return; } - u.fadeIn(this.el, _.bind(this.afterShown, this, focus)); + u.fadeIn(this.el, _.bind(this.afterShown, this)); }, - show (focus) { + show () { if (_.isUndefined(this.debouncedShow)) { /* We wrap the method in a debouncer and set it on the * instance, so that we have it debounced per instance. diff --git a/src/converse-muc-views.js b/src/converse-muc-views.js index 5950ede6a..e4a727a06 100644 --- a/src/converse-muc-views.js +++ b/src/converse-muc-views.js @@ -517,7 +517,7 @@ })); }, - afterShown (focus) { + afterShown () { /* Override from converse-chatview, specifically to avoid * the 'active' chat state from being sent out prematurely. * @@ -530,18 +530,17 @@ this.occupantsview.setOccupantsHeight(); this.scrollDown(); this.renderEmojiPicker(); - if (focus) { this.focus(); } }, - show (focus) { + show () { if (u.isVisible(this.el)) { - if (focus) { this.focus(); } + this.focus(); return; } // Override from converse-chatview in order to not use // "fadeIn", which causes flashing. u.showElement(this.el); - this.afterShown(focus); + this.afterShown(); }, afterConnected () {