Commit 044907e4 authored by JC Brand's avatar JC Brand

Looks like `focus` parameter was never used.

parent 401513e6
...@@ -224,16 +224,19 @@ ...@@ -224,16 +224,19 @@
// visible, but no other chat boxes have been created. // visible, but no other chat boxes have been created.
expect(_converse.chatboxes.length).toEqual(1); expect(_converse.chatboxes.length).toEqual(1);
spyOn(_converse.ChatBoxView.prototype, 'focus');
chatbox = test_utils.openChatBoxFor(_converse, contact_jid); chatbox = test_utils.openChatBoxFor(_converse, contact_jid);
$el = $(_converse.rosterview.el).find('a.open-chat:contains("'+chatbox.get('fullname')+'")'); $el = $(_converse.rosterview.el).find('a.open-chat:contains("'+chatbox.get('fullname')+'")');
jid = $el.text().replace(/ /g,'.').toLowerCase() + '@localhost'; jid = $el.text().replace(/ /g,'.').toLowerCase() + '@localhost';
spyOn(_converse, 'emit');
$el[0].click(); $el[0].click();
expect(_converse.chatboxes.length).toEqual(2); test_utils.waitUntil(function () {
var chatboxview = _converse.chatboxviews.get(contact_jid); return _converse.emit.calls.count();
expect(chatboxview.focus).toHaveBeenCalled(); }, 300).then(function () {
done(); expect(_converse.chatboxes.length).toEqual(2);
expect(_converse.emit).toHaveBeenCalledWith('chatBoxFocused', jasmine.any(Object));
done();
});
})); }));
...@@ -280,9 +283,8 @@ ...@@ -280,9 +283,8 @@
test_utils.createContacts(_converse, 'current'); test_utils.createContacts(_converse, 'current');
test_utils.openControlBox(); test_utils.openControlBox();
test_utils.waitUntil(function () { test_utils.waitUntil(function () {
return $(_converse.rosterview.el).find('.roster-group').length; return $(_converse.rosterview.el).find('.roster-group').length;
}, 300) }, 300).then(function () {
.then(function () {
var chatbox = test_utils.openChatBoxes(_converse, 1)[0], var chatbox = test_utils.openChatBoxes(_converse, 1)[0],
controlview = _converse.chatboxviews.get('controlbox'), // The controlbox is currently open controlview = _converse.chatboxviews.get('controlbox'), // The controlbox is currently open
chatview = _converse.chatboxviews.get(chatbox.get('jid')); chatview = _converse.chatboxviews.get(chatbox.get('jid'));
......
...@@ -1083,7 +1083,7 @@ ...@@ -1083,7 +1083,7 @@
return this; return this;
}, },
afterShown (focus) { afterShown () {
if (u.isPersistableModel(this.model)) { if (u.isPersistableModel(this.model)) {
this.model.clearUnreadMsgCounter(); this.model.clearUnreadMsgCounter();
this.model.save(); this.model.save();
...@@ -1091,21 +1091,18 @@ ...@@ -1091,21 +1091,18 @@
this.setChatState(_converse.ACTIVE); this.setChatState(_converse.ACTIVE);
this.renderEmojiPicker(); this.renderEmojiPicker();
this.scrollDown(); this.scrollDown();
if (focus) {
this.focus();
}
}, },
_show (focus) { _show (f) {
/* Inner show method that gets debounced */ /* Inner show method that gets debounced */
if (u.isVisible(this.el)) { if (u.isVisible(this.el)) {
if (focus) { this.focus(); } this.focus();
return; 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)) { if (_.isUndefined(this.debouncedShow)) {
/* We wrap the method in a debouncer and set it on the /* We wrap the method in a debouncer and set it on the
* instance, so that we have it debounced per instance. * instance, so that we have it debounced per instance.
......
...@@ -517,7 +517,7 @@ ...@@ -517,7 +517,7 @@
})); }));
}, },
afterShown (focus) { afterShown () {
/* Override from converse-chatview, specifically to avoid /* Override from converse-chatview, specifically to avoid
* the 'active' chat state from being sent out prematurely. * the 'active' chat state from being sent out prematurely.
* *
...@@ -530,18 +530,17 @@ ...@@ -530,18 +530,17 @@
this.occupantsview.setOccupantsHeight(); this.occupantsview.setOccupantsHeight();
this.scrollDown(); this.scrollDown();
this.renderEmojiPicker(); this.renderEmojiPicker();
if (focus) { this.focus(); }
}, },
show (focus) { show () {
if (u.isVisible(this.el)) { if (u.isVisible(this.el)) {
if (focus) { this.focus(); } this.focus();
return; return;
} }
// Override from converse-chatview in order to not use // Override from converse-chatview in order to not use
// "fadeIn", which causes flashing. // "fadeIn", which causes flashing.
u.showElement(this.el); u.showElement(this.el);
this.afterShown(focus); this.afterShown();
}, },
afterConnected () { afterConnected () {
......
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