Commit 03d7f07a authored by JC Brand's avatar JC Brand

Bugfix. Chat wasn't being opened when receiving a message.

parent ca141401
...@@ -56,13 +56,14 @@ ...@@ -56,13 +56,14 @@
null, ['rosterGroupsFetched'], {}, null, ['rosterGroupsFetched'], {},
function (done, _converse) { function (done, _converse) {
var view;
test_utils.createContacts(_converse, 'current');
test_utils.waitUntilDiscoConfirmed(_converse, 'localhost', [], ['vcard-temp']) test_utils.waitUntilDiscoConfirmed(_converse, 'localhost', [], ['vcard-temp'])
.then(function () { .then(function () {
return test_utils.waitUntil(function () { return test_utils.waitUntil(function () {
return _converse.xmppstatus.get('fullname'); return _converse.xmppstatus.get('fullname');
}, 300); }, 300);
}).then(function () { }).then(function () {
test_utils.createContacts(_converse, 'current');
test_utils.openControlBox(); test_utils.openControlBox();
expect(_converse.chatboxes.length).toEqual(1); expect(_converse.chatboxes.length).toEqual(1);
var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
...@@ -76,8 +77,12 @@ ...@@ -76,8 +77,12 @@
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree(); .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
_converse.chatboxes.onMessage(msg); _converse.chatboxes.onMessage(msg);
var view = _converse.chatboxviews.get(sender_jid); view = _converse.chatboxviews.get(sender_jid);
expect(_.includes($(view.el).find('.chat-msg-author').text(), '**Max Frankfurter')).toBeTruthy();
test_utils.waitUntil(function () {
return u.isVisible(view.el);
}).then(function () {
expect(_.includes(view.el.querySelector('.chat-msg-author').textContent, '**Max Frankfurter')).toBeTruthy();
expect($(view.el).find('.chat-msg-content').text()).toBe(' is tired'); expect($(view.el).find('.chat-msg-content').text()).toBe(' is tired');
message = '/me is as well'; message = '/me is as well';
...@@ -86,6 +91,7 @@ ...@@ -86,6 +91,7 @@
expect($(view.el).find('.chat-msg-content:last').text()).toBe(' is as well'); expect($(view.el).find('.chat-msg-content:last').text()).toBe(' is as well');
done(); done();
}); });
});
})); }));
it("is created when you click on a roster item", it("is created when you click on a roster item",
...@@ -189,7 +195,7 @@ ...@@ -189,7 +195,7 @@
test_utils.createContacts(_converse, 'current'); test_utils.createContacts(_converse, 'current');
var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost'; var sender_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
var chat = _converse.api.chats.open(sender_jid, { var chat = _converse.api.chats.create(sender_jid, {
minimized: true minimized: true
}); });
......
...@@ -367,10 +367,14 @@ ...@@ -367,10 +367,14 @@
attrs = jid; attrs = jid;
jid = attrs.jid; jid = attrs.jid;
} }
jid = jid.toLowerCase(); jid = Strophe.getBareJidFromJid(jid.toLowerCase());
attrs.jid = jid; attrs.jid = jid;
attrs.id = jid; attrs.id = jid;
if (!attrs.fullname) {
const roster_item = _converse.roster.get(jid);
attrs.fullname = roster_item.get('fullname');
}
let chatbox = this.get(Strophe.getBareJidFromJid(jid)); let chatbox = this.get(Strophe.getBareJidFromJid(jid));
if (!chatbox && create) { if (!chatbox && create) {
chatbox = this.create(attrs, { chatbox = this.create(attrs, {
......
...@@ -688,6 +688,10 @@ ...@@ -688,6 +688,10 @@
return message; return message;
}, },
shouldShowOnTextMessage () {
return !u.isVisible(this.el);
},
handleTextMessage (message) { handleTextMessage (message) {
this.showMessage(_.clone(message.attributes)); this.showMessage(_.clone(message.attributes));
if (u.isNewMessage(message)) { if (u.isNewMessage(message)) {
...@@ -701,7 +705,11 @@ ...@@ -701,7 +705,11 @@
this.showNewMessagesIndicator(); this.showNewMessagesIndicator();
} }
} }
if (this.shouldShowOnTextMessage()) {
this.show();
} else {
this.scrollDown(); this.scrollDown();
}
}, },
handleErrorMessage (message) { handleErrorMessage (message) {
......
...@@ -116,6 +116,11 @@ ...@@ -116,6 +116,11 @@
this.__super__.isNewMessageHidden.apply(this, arguments); this.__super__.isNewMessageHidden.apply(this, arguments);
}, },
shouldShowOnTextMessage () {
return !this.model.get('minimized') &&
this.__super__.shouldShowOnTextMessage.apply(this, arguments);
},
setChatBoxHeight (height) { setChatBoxHeight (height) {
if (!this.model.get('minimized')) { if (!this.model.get('minimized')) {
return this.__super__.setChatBoxHeight.apply(this, arguments); return this.__super__.setChatBoxHeight.apply(this, arguments);
......
...@@ -691,11 +691,8 @@ ...@@ -691,11 +691,8 @@
// assigned to their various groups. // assigned to their various groups.
_converse.on('rosterGroupsFetched', this.sortAndPositionAllItems.bind(this)); _converse.on('rosterGroupsFetched', this.sortAndPositionAllItems.bind(this));
// _converse.on('rosterGroupsFetched', this.positionFetchedGroups, this);
_converse.on('rosterContactsFetched', () => { _converse.on('rosterContactsFetched', () => {
_converse.roster.each((contact) => { _converse.roster.each((contact) => this.addRosterContact(contact, {'silent': true}));
this.addRosterContact(contact, {'silent': true});
});
this.update(); this.update();
this.updateFilter(); this.updateFilter();
this.trigger('rosterContactsFetchedAndProcessed'); this.trigger('rosterContactsFetchedAndProcessed');
......
...@@ -63,6 +63,10 @@ ...@@ -63,6 +63,10 @@
}, },
ChatBoxView: { ChatBoxView: {
shouldShowOnTextMessage () {
return false;
},
_show (focus) { _show (focus) {
/* We only have one chat visible at any one /* We only have one chat visible at any one
* time. So before opening a chat, we make sure all other * time. So before opening a chat, we make sure all other
......
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