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