MUC: Don't show duplicate join
messages.
This commit is contained in:
parent
21fbb7b7ac
commit
f2f05ff484
|
@ -1,5 +1,5 @@
|
|||
define("transcripts", [
|
||||
"tpl!converse-logs/conversejs.containers-1460718487729",
|
||||
"tpl!converse-logs/double_logins",
|
||||
], function () {
|
||||
return arguments;
|
||||
});
|
||||
|
|
|
@ -400,7 +400,7 @@
|
|||
}).up()
|
||||
.c('status', {code: '110'});
|
||||
_converse.connection._dataRecv(test_utils.createRequest(presence));
|
||||
expect($chat_content.find('div.chat-info:first').html()).toBe("some1 has joined the room");
|
||||
expect($chat_content.find('div.chat-info:first').html()).toBe("some1 has joined the room.");
|
||||
|
||||
presence = $pres({
|
||||
to: 'dummy@localhost/_converse.js-29092160',
|
||||
|
@ -413,7 +413,20 @@
|
|||
});
|
||||
_converse.connection._dataRecv(test_utils.createRequest(presence));
|
||||
expect($chat_content.find('div.chat-info').length).toBe(2);
|
||||
expect($chat_content.find('div.chat-info:last').html()).toBe("newguy has joined the room");
|
||||
expect($chat_content.find('div.chat-info:last').html()).toBe("newguy has joined the room.");
|
||||
|
||||
// Don't show duplicate join messages
|
||||
presence = $pres({
|
||||
to: 'dummy@localhost/_converse.js-290918392',
|
||||
from: 'coven@chat.shakespeare.lit/newguy'
|
||||
}).c('x', {xmlns: Strophe.NS.MUC_USER})
|
||||
.c('item', {
|
||||
'affiliation': 'none',
|
||||
'jid': 'newguy@localhost/_converse.js-290929789',
|
||||
'role': 'participant'
|
||||
});
|
||||
_converse.connection._dataRecv(test_utils.createRequest(presence));
|
||||
expect($chat_content.find('div.chat-info').length).toBe(2);
|
||||
|
||||
presence = $pres({
|
||||
to: 'dummy@localhost/_converse.js-29092160',
|
||||
|
@ -1203,7 +1216,7 @@
|
|||
expect($occupants.children().first(0).text()).toBe("oldnick");
|
||||
|
||||
expect($chat_content.find('div.chat-info').length).toBe(2);
|
||||
expect($chat_content.find('div.chat-info:first').html()).toBe("oldnick has joined the room");
|
||||
expect($chat_content.find('div.chat-info:first').html()).toBe("oldnick has joined the room.");
|
||||
expect($chat_content.find('div.chat-info:last').html()).toBe(__(_converse.muc.new_nickname_messages["210"], "oldnick"));
|
||||
|
||||
presence = $pres().attrs({
|
||||
|
@ -1245,7 +1258,7 @@
|
|||
_converse.connection._dataRecv(test_utils.createRequest(presence));
|
||||
expect($chat_content.find('div.chat-info').length).toBe(4);
|
||||
expect($chat_content.find('div.chat-info').get(2).textContent).toBe(__(_converse.muc.new_nickname_messages["303"], "newnick"));
|
||||
expect($chat_content.find('div.chat-info').last().html()).toBe("newnick has joined the room");
|
||||
expect($chat_content.find('div.chat-info').last().html()).toBe("newnick has joined the room.");
|
||||
$occupants = view.$('.occupant-list');
|
||||
expect($occupants.children().length).toBe(1);
|
||||
expect($occupants.children().first(0).text()).toBe("newnick");
|
||||
|
|
|
@ -50,10 +50,10 @@
|
|||
|
||||
it("can be used to replay conversations", mock.initConverse(function (_converse) {
|
||||
/*
|
||||
test_utils.openChatRoom(_converse, "dummy", 'rooms.localhost', 'jc');
|
||||
test_utils.openChatRoom(_converse, "prosody", 'conference.prosody.im', 'jc');
|
||||
test_utils.openAndEnterChatRoom(_converse, "dummy", 'rooms.localhost', 'jc');
|
||||
test_utils.openAndEnterChatRoom(_converse, "prosody", 'conference.prosody.im', 'jc');
|
||||
*/
|
||||
test_utils.openChatRoom(_converse, "discuss", 'conference.conversejs.org', 'ee');
|
||||
test_utils.openAndEnterChatRoom(_converse, "discuss", 'conference.conversejs.org', 'jc');
|
||||
spyOn(_converse, 'areDesktopNotificationsEnabled').andReturn(true);
|
||||
_.each(transcripts, function (transcript) {
|
||||
var text = transcript();
|
||||
|
|
|
@ -1702,15 +1702,24 @@
|
|||
// result look like the structure returned by
|
||||
// parseXUserElement. Not nice...
|
||||
var nick = Strophe.getResourceFromJid(stanza.getAttribute('from'));
|
||||
var stat = stanza.querySelector('status');
|
||||
if (stanza.getAttribute('type') === 'unavailable') {
|
||||
var stat = stanza.querySelector('status');
|
||||
if (!_.isNull(stat) && stat.textContent) {
|
||||
return [{'messages': [__(nick+' has left the room. "'+stat.textContent+'"')]}];
|
||||
} else {
|
||||
return [{'messages': [__(nick+' has left the room')]}];
|
||||
}
|
||||
}
|
||||
return [{'messages': [__(nick+' has joined the room')]}];
|
||||
if (!this.occupantsview.model.find({'nick': nick})) {
|
||||
// Only show join message if we don't already have the
|
||||
// occupant model. Doing so avoids showing duplicate
|
||||
// join messages.
|
||||
if (!_.isNull(stat) && stat.textContent) {
|
||||
return [{'messages': [__(nick+' has joined the room. "'+stat.textContent+'"')]}];
|
||||
} else {
|
||||
return [{'messages': [__(nick+' has joined the room.')]}];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
showStatusMessages: function (stanza) {
|
||||
|
@ -1837,6 +1846,8 @@
|
|||
this.getRoomFeatures();
|
||||
}
|
||||
this.hideSpinner().showStatusMessages(pres);
|
||||
// This must be called after showStatusMessages so that
|
||||
// "join" messages are correctly shown.
|
||||
this.occupantsview.updateOccupantsOnPresence(pres);
|
||||
if (this.model.get('role') !== 'none' &&
|
||||
this.model.get('connection_status') === ROOMSTATUS.CONNECTING) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user