Don't set nick before confirmation that it was successful
This commit is contained in:
parent
d385452a7d
commit
a0f0240b92
@ -1105,12 +1105,16 @@ converse.plugins.add('converse-muc-views', {
|
|||||||
case 'nick': {
|
case 'nick': {
|
||||||
if (!this.verifyRoles(['visitor', 'participant', 'moderator'])) {
|
if (!this.verifyRoles(['visitor', 'participant', 'moderator'])) {
|
||||||
break;
|
break;
|
||||||
|
} else if (args.length === 0) {
|
||||||
|
this.showErrorMessage(__('You need to provide a nickname'))
|
||||||
|
} else {
|
||||||
|
const jid = Strophe.getBareJidFromJid(this.model.get('jid'));
|
||||||
|
_converse.api.send($pres({
|
||||||
|
from: _converse.connection.jid,
|
||||||
|
to: `${jid}/${args}`,
|
||||||
|
id: _converse.connection.getUniqueId()
|
||||||
|
}).tree());
|
||||||
}
|
}
|
||||||
_converse.api.send($pres({
|
|
||||||
from: _converse.connection.jid,
|
|
||||||
to: this.model.getRoomJIDAndNick(args),
|
|
||||||
id: _converse.connection.getUniqueId()
|
|
||||||
}).tree());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'owner':
|
case 'owner':
|
||||||
|
@ -377,7 +377,7 @@ converse.plugins.add('converse-muc', {
|
|||||||
}
|
}
|
||||||
const stanza = $pres({
|
const stanza = $pres({
|
||||||
'from': _converse.connection.jid,
|
'from': _converse.connection.jid,
|
||||||
'to': this.getRoomJIDAndNick(nick)
|
'to': this.getRoomJIDAndNick()
|
||||||
}).c("x", {'xmlns': Strophe.NS.MUC})
|
}).c("x", {'xmlns': Strophe.NS.MUC})
|
||||||
.c("history", {'maxstanzas': this.features.get('mam_enabled') ? 0 : _converse.muc_history_max_stanzas}).up();
|
.c("history", {'maxstanzas': this.features.get('mam_enabled') ? 0 : _converse.muc_history_max_stanzas}).up();
|
||||||
|
|
||||||
@ -532,30 +532,25 @@ converse.plugins.add('converse-muc', {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getRoomJIDAndNick (nick) {
|
/**
|
||||||
/* Utility method to construct the JID for the current user
|
* Utility method to construct the JID for the current user
|
||||||
* as occupant of the groupchat.
|
* as occupant of the groupchat.
|
||||||
*
|
*
|
||||||
* This is the groupchat JID, with the user's nick added at the
|
* @returns {string} - The groupchat JID with the user's nickname added at the end.
|
||||||
* end.
|
* @example groupchat@conference.example.org/nickname
|
||||||
*
|
*/
|
||||||
* For example: groupchat@conference.example.org/nickname
|
getRoomJIDAndNick () {
|
||||||
*/
|
const nick = this.get('nick');
|
||||||
if (nick) {
|
const jid = Strophe.getBareJidFromJid(this.get('jid'));
|
||||||
this.save({'nick': nick});
|
|
||||||
} else {
|
|
||||||
nick = this.get('nick');
|
|
||||||
}
|
|
||||||
const groupchat = this.get('jid');
|
|
||||||
const jid = Strophe.getBareJidFromJid(groupchat);
|
|
||||||
return jid + (nick !== null ? `/${nick}` : "");
|
return jid + (nick !== null ? `/${nick}` : "");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a message with the status of the user in this chat session
|
||||||
|
* as taken from the 'chat_state' attribute of the chat box.
|
||||||
|
* See XEP-0085 Chat State Notifications.
|
||||||
|
*/
|
||||||
sendChatState () {
|
sendChatState () {
|
||||||
/* Sends a message with the status of the user in this chat session
|
|
||||||
* as taken from the 'chat_state' attribute of the chat box.
|
|
||||||
* See XEP-0085 Chat State Notifications.
|
|
||||||
*/
|
|
||||||
if (!_converse.send_chat_state_notifications || this.get('connection_status') !== converse.ROOMSTATUS.ENTERED) {
|
if (!_converse.send_chat_state_notifications || this.get('connection_status') !== converse.ROOMSTATUS.ENTERED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user