New config option muc_show_disconnection_status

This commit is contained in:
JC Brand 2019-05-14 13:01:07 +02:00
parent 6193a9dc80
commit d0ddda8244
4 changed files with 51 additions and 1 deletions

View File

@ -12,6 +12,7 @@
- Continuously retry (in 2s intervals) to fetch login credentials (via [credentials_url](https://conversejs.org/docs/html/configuration.html#credentials-url)) in case of failure - Continuously retry (in 2s intervals) to fetch login credentials (via [credentials_url](https://conversejs.org/docs/html/configuration.html#credentials-url)) in case of failure
- Replace `moment` with [DayJS](https://github.com/iamkun/dayjs). - Replace `moment` with [DayJS](https://github.com/iamkun/dayjs).
- New API method [\_converse.api.disco.features.get](https://conversejs.org/docs/html/api/-_converse.api.disco.features.html#.get) - New API method [\_converse.api.disco.features.get](https://conversejs.org/docs/html/api/-_converse.api.disco.features.html#.get)
- New config setting [muc_show_disconnection_status](https://conversejs.org/docs/html/configuration.html#muc-show-disconnection-status)
- #1296: `embedded` view mode shows `chatbox-navback` arrow in header - #1296: `embedded` view mode shows `chatbox-navback` arrow in header
- #1465: When highlighting a roster contact, they're incorrectly shown as online - #1465: When highlighting a roster contact, they're incorrectly shown as online
- #1532: Converse reloads on enter pressed in the filter box - #1532: Converse reloads on enter pressed in the filter box

View File

@ -1026,6 +1026,16 @@ all MUCs with set autojoin flag in their respective bookmarks will be joined on
startup of Converse. When set to ``false`` no MUCs are automatically joined based on startup of Converse. When set to ``false`` no MUCs are automatically joined based on
their bookmarks. their bookmarks.
muc_show_disconnection_status
-----------------------------
* Default; ``true``
Determines whether Converse shows the optionally included status message when a
user leaves the MUC.
See https://xmpp.org/extensions/xep-0045.html#changepres
muc_show_join_leave muc_show_join_leave
------------------- -------------------

View File

@ -896,6 +896,44 @@
done(); done();
})); }));
it("doesn't show the disconnection status when muc_show_disconnection_status is false",
mock.initConverse(
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {'muc_show_disconnection_status': false},
async function (done, _converse) {
await test_utils.openChatRoom(_converse, "coven", 'chat.shakespeare.lit', 'some1');
const view = _converse.chatboxviews.get('coven@chat.shakespeare.lit');
const chat_content = view.el.querySelector('.chat-content');
let presence = $pres({
to: 'dummy@localhost/resource',
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.querySelectorAll('div.chat-info').length).toBe(0);
presence = $pres({
to: 'dummy@localhost/resource',
type: 'unavailable',
from: 'coven@chat.shakespeare.lit/newguy'
})
.c('status', 'Disconnected: Replaced by new connection').up()
.c('x', {xmlns: Strophe.NS.MUC_USER})
.c('item', {
'affiliation': 'none',
'jid': 'newguy@localhost/_converse.js-290929789',
'role': 'none'
});
_converse.connection._dataRecv(test_utils.createRequest(presence));
expect(chat_content.querySelectorAll('div.chat-info').length).toBe(1);
expect(sizzle('div.chat-info', chat_content).pop().textContent).toBe('newguy has left the groupchat');
done();
}));
it("role-change messages that follow a MUC leave are left out", it("role-change messages that follow a MUC leave are left out",
mock.initConverse( mock.initConverse(
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {}, null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},

View File

@ -117,6 +117,7 @@ converse.plugins.add('converse-muc-views', {
'locked_muc_nickname': false, 'locked_muc_nickname': false,
'muc_disable_slash_commands': false, 'muc_disable_slash_commands': false,
'muc_domain': undefined, 'muc_domain': undefined,
'muc_show_disconnection_status': true,
'muc_show_join_leave': true, 'muc_show_join_leave': true,
'roomconfig_whitelist': [], 'roomconfig_whitelist': [],
'visible_toolbar_buttons': { 'visible_toolbar_buttons': {
@ -1651,7 +1652,7 @@ converse.plugins.add('converse-muc-views', {
return; return;
} }
const nick = occupant.get('nick'), const nick = occupant.get('nick'),
stat = occupant.get('status'), stat = _converse.muc_show_disconnection_status ? occupant.get('status') : null,
prev_info_el = this.getPreviousJoinOrLeaveNotification(this.content.lastElementChild, nick), prev_info_el = this.getPreviousJoinOrLeaveNotification(this.content.lastElementChild, nick),
dataset = _.get(prev_info_el, 'dataset', {}); dataset = _.get(prev_info_el, 'dataset', {});