Fixed typing status for typing from different devices (#802)
This commit is contained in:
parent
24b39b3ee9
commit
c976f3f079
|
@ -4,7 +4,8 @@
|
|||
|
||||
- #585 Duplicate contact created due to JID case sensivity [saganshul]
|
||||
- #628 Fixes the bug in displaying chat status during private chat. [saganshul]
|
||||
- #797 Time format made configurable. [smitbose]
|
||||
- #628 Changes the message displayed while typing from a different resource of the same user. [smitbose]
|
||||
- #675 Time format made configurable. [smitbose]
|
||||
- #806 The `_converse.listen` API event listeners aren't triggered. [jcbrand]
|
||||
- #807 Error: Plugin "converse-dragresize" tried to override HeadlinesBoxView but it's not found. [jcbrand]
|
||||
|
||||
|
|
|
@ -1393,6 +1393,43 @@
|
|||
var $events = chatboxview.$el.find('.chat-event');
|
||||
expect($events.text()).toEqual(mock.cur_names[1] + ' is typing');
|
||||
}));
|
||||
|
||||
it("can be a composing carbon message that this user sent from a different client", mock.initConverse(function (_converse) {
|
||||
test_utils.createContacts(_converse, 'current');
|
||||
|
||||
// Send a message from a different resource
|
||||
spyOn(_converse, 'log');
|
||||
var recipient_jid = mock.cur_names[5].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||
test_utils.openChatBoxFor(_converse, recipient_jid);
|
||||
var msg = $msg({
|
||||
'from': _converse.bare_jid,
|
||||
'id': (new Date()).getTime(),
|
||||
'to': _converse.connection.jid,
|
||||
'type': 'chat',
|
||||
'xmlns': 'jabber:client'
|
||||
}).c('sent', {'xmlns': 'urn:xmpp:carbons:2'})
|
||||
.c('forwarded', {'xmlns': 'urn:xmpp:forward:0'})
|
||||
.c('message', {
|
||||
'xmlns': 'jabber:client',
|
||||
'from': _converse.bare_jid+'/another-resource',
|
||||
'to': recipient_jid,
|
||||
'type': 'chat'
|
||||
}).c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree();
|
||||
_converse.chatboxes.onMessage(msg);
|
||||
|
||||
// Check that the chatbox and its view now exist
|
||||
var chatbox = _converse.chatboxes.get(recipient_jid);
|
||||
var chatboxview = _converse.chatboxviews.get(recipient_jid);
|
||||
// Check that the message was received and check the message parameters
|
||||
expect(chatbox.messages.length).toEqual(1);
|
||||
var msg_obj = chatbox.messages.models[0];
|
||||
expect(msg_obj.get('fullname')).toEqual(_converse.xmppstatus.get('fullname'));
|
||||
expect(msg_obj.get('sender')).toEqual('me');
|
||||
expect(msg_obj.get('delayed')).toEqual(false);
|
||||
var $chat_content = chatboxview.$el.find('.chat-content');
|
||||
var status_text = $chat_content.find('.chat-info.chat-event').text();
|
||||
expect(status_text).toBe('Typing from another device');
|
||||
}));
|
||||
});
|
||||
|
||||
describe("A paused notification", function () {
|
||||
|
@ -1477,6 +1514,43 @@
|
|||
var $events = chatboxview.$el.find('.chat-event');
|
||||
expect($events.text()).toEqual(mock.cur_names[1] + ' has stopped typing');
|
||||
}));
|
||||
|
||||
it("can be a paused carbon message that this user sent from a different client", mock.initConverse(function (_converse) {
|
||||
test_utils.createContacts(_converse, 'current');
|
||||
|
||||
// Send a message from a different resource
|
||||
spyOn(_converse, 'log');
|
||||
var recipient_jid = mock.cur_names[5].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||
test_utils.openChatBoxFor(_converse, recipient_jid);
|
||||
var msg = $msg({
|
||||
'from': _converse.bare_jid,
|
||||
'id': (new Date()).getTime(),
|
||||
'to': _converse.connection.jid,
|
||||
'type': 'chat',
|
||||
'xmlns': 'jabber:client'
|
||||
}).c('sent', {'xmlns': 'urn:xmpp:carbons:2'})
|
||||
.c('forwarded', {'xmlns': 'urn:xmpp:forward:0'})
|
||||
.c('message', {
|
||||
'xmlns': 'jabber:client',
|
||||
'from': _converse.bare_jid+'/another-resource',
|
||||
'to': recipient_jid,
|
||||
'type': 'chat'
|
||||
}).c('paused', {'xmlns': Strophe.NS.CHATSTATES}).tree();
|
||||
_converse.chatboxes.onMessage(msg);
|
||||
|
||||
// Check that the chatbox and its view now exist
|
||||
var chatbox = _converse.chatboxes.get(recipient_jid);
|
||||
var chatboxview = _converse.chatboxviews.get(recipient_jid);
|
||||
// Check that the message was received and check the message parameters
|
||||
expect(chatbox.messages.length).toEqual(1);
|
||||
var msg_obj = chatbox.messages.models[0];
|
||||
expect(msg_obj.get('fullname')).toEqual(_converse.xmppstatus.get('fullname'));
|
||||
expect(msg_obj.get('sender')).toEqual('me');
|
||||
expect(msg_obj.get('delayed')).toEqual(false);
|
||||
var $chat_content = chatboxview.$el.find('.chat-content');
|
||||
var status_text = $chat_content.find('.chat-info.chat-event').text();
|
||||
expect(status_text).toBe('Stopped typing on the other device');
|
||||
}));
|
||||
});
|
||||
|
||||
describe("An inactive notifciation", function () {
|
||||
|
|
|
@ -376,10 +376,20 @@
|
|||
|
||||
handleChatStateMessage: function (message) {
|
||||
if (message.get('chat_state') === _converse.COMPOSING) {
|
||||
this.showStatusNotification(message.get('fullname')+' '+__('is typing'));
|
||||
if(message.get('sender') === 'me') {
|
||||
this.showStatusNotification(__('Typing from another device'));
|
||||
}
|
||||
else {
|
||||
this.showStatusNotification(message.get('fullname')+' '+__('is typing'));
|
||||
}
|
||||
this.clear_status_timeout = window.setTimeout(this.clearStatusNotification.bind(this), 30000);
|
||||
} else if (message.get('chat_state') === _converse.PAUSED) {
|
||||
this.showStatusNotification(message.get('fullname')+' '+__('has stopped typing'));
|
||||
if(message.get('sender') === 'me') {
|
||||
this.showStatusNotification(__('Stopped typing on the other device'));
|
||||
}
|
||||
else {
|
||||
this.showStatusNotification(message.get('fullname')+' '+__('has stopped typing'));
|
||||
}
|
||||
} else if (_.includes([_converse.INACTIVE, _converse.ACTIVE], message.get('chat_state'))) {
|
||||
this.$content.find('div.chat-event').remove();
|
||||
} else if (message.get('chat_state') === _converse.GONE) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user