Commit 27bc33ba authored by JC Brand's avatar JC Brand

Use nickname from global settings when entering a room

parent bfb7ea4f
......@@ -2659,6 +2659,19 @@
describe("When attempting to enter a groupchat", function () {
it("will use the nickname set in the global settings if the user doesn't have a VCard nickname",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {'nickname': 'Benedict-Cucumberpatch'},
function (done, _converse) {
test_utils.openChatRoomViaModal(_converse, 'problematic@muc.localhost')
.then(function () {
const view = _converse.chatboxviews.get('problematic@muc.localhost');
expect(view.model.get('nick')).toBe('Benedict-Cucumberpatch');
done();
}).catch(_.partial(console.error, _));
}));
it("will show an error message if the groupchat requires a password",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
......
......@@ -812,7 +812,7 @@
defaults () {
return {
"jid": _converse.bare_jid,
"status": _converse.default_state,
"status": _converse.default_state
}
},
......
......@@ -477,6 +477,10 @@
openChatRoom (ev) {
ev.preventDefault();
const data = this.parseRoomDataFromEvent(ev.target);
if (data.nick === "") {
// Make sure defaults apply if no nick is provided.
data.nick = undefined;
}
_converse.api.rooms.open(data.jid, data);
this.modal.hide();
ev.target.reset();
......
......@@ -171,7 +171,7 @@
'affiliation': null,
'connection_status': converse.ROOMSTATUS.DISCONNECTED,
'name': '',
'nick': _converse.xmppstatus.get('nickname'),
'nick': _converse.xmppstatus.get('nickname') || _converse.nickname,
'description': '',
'features_fetched': false,
'roomconfig': {},
......
......@@ -103,18 +103,18 @@
return utils.waitUntil(() => _converse.chatboxviews.get(jid));
};
utils.openChatRoomViaModal = function (_converse, jid, nick) {
utils.openChatRoomViaModal = function (_converse, jid, nick='') {
// Opens a new chatroom
return new Promise(function (resolve, reject) {
utils.openControlBox(_converse);
var roomspanel = _converse.chatboxviews.get('controlbox').roomspanel;
const roomspanel = _converse.chatboxviews.get('controlbox').roomspanel;
roomspanel.el.querySelector('.show-add-muc-modal').click();
utils.closeControlBox(_converse);
const modal = roomspanel.add_room_modal;
utils.waitUntil(function () {
return u.isVisible(modal.el);
}, 1000).then(function () {
utils.waitUntil(() => u.isVisible(modal.el), 1000)
.then(() => {
modal.el.querySelector('input[name="chatroom"]').value = jid;
modal.el.querySelector('input[name="nickname"]').value = nick;
modal.el.querySelector('form input[type="submit"]').click();
resolve();
}).catch(_.partial(console.error, _));
......
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