feat(DisplayName): Limit local and remote display name to 50 chars

This commit is contained in:
hristoterezov 2016-11-01 16:40:52 -05:00
parent 3ad1573130
commit a6a7e81a0f
1 changed files with 16 additions and 7 deletions

View File

@ -54,6 +54,12 @@ const commands = {
CUSTOM_ROLE: "custom-role"
};
/**
* Max length of the display names. If we receive longer display name the
* additional chars are going to be cut.
*/
const MAX_DISPLAYNAME_LENGTH = 50;
/**
* Open Connection. When authentication failed it shows auth dialog.
* @param roomName the room name to use
@ -281,15 +287,16 @@ function changeLocalEmail(email = '') {
* @param nickname {string} the new display name
*/
function changeLocalDisplayName(nickname = '') {
nickname = nickname.trim();
const formattedNickname
= nickname.trim().substr(0, MAX_DISPLAYNAME_LENGTH);
if (nickname === APP.settings.getDisplayName()) {
if (formattedNickname === APP.settings.getDisplayName()) {
return;
}
APP.settings.setDisplayName(nickname);
room.setDisplayName(nickname);
APP.UI.changeDisplayName(APP.conference.getMyUserId(), nickname);
APP.settings.setDisplayName(formattedNickname);
room.setDisplayName(formattedNickname);
APP.UI.changeDisplayName(APP.conference.getMyUserId(), formattedNickname);
}
class ConferenceConnector {
@ -1268,8 +1275,10 @@ export default {
});
room.on(ConferenceEvents.DISPLAY_NAME_CHANGED, (id, displayName) => {
APP.API.notifyDisplayNameChanged(id, displayName);
APP.UI.changeDisplayName(id, displayName);
const formattedDisplayName
= displayName.substr(0, MAX_DISPLAYNAME_LENGTH);
APP.API.notifyDisplayNameChanged(id, formattedDisplayName);
APP.UI.changeDisplayName(id, formattedDisplayName);
});
room.on(ConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,