@ -30,7 +30,8 @@ import {
toggleAudioOnly ,
EMAIL _COMMAND ,
lockStateChanged ,
p2pStatusChanged
p2pStatusChanged ,
setLocalParticipantData
} from './react/features/base/conference' ;
import { updateDeviceList } from './react/features/base/devices' ;
import {
@ -55,6 +56,8 @@ import {
} from './react/features/base/media' ;
import {
dominantSpeakerChanged ,
getLocalParticipant ,
getParticipantById ,
localParticipantConnectionStatusChanged ,
localParticipantRoleChanged ,
MAX _DISPLAY _NAME _LENGTH ,
@ -143,43 +146,15 @@ function sendData(command, value) {
room . sendCommand ( command , { value : value } ) ;
}
/ * *
* Sets up initially the properties of the local participant - email , avatarID ,
* avatarURL , displayName , etc .
* /
function _setupLocalParticipantProperties ( ) {
const email = APP . settings . getEmail ( ) ;
email && sendData ( commands . EMAIL , email ) ;
const avatarUrl = APP . settings . getAvatarUrl ( ) ;
avatarUrl && sendData ( commands . AVATAR _URL , avatarUrl ) ;
if ( ! email && ! avatarUrl ) {
sendData ( commands . AVATAR _ID , APP . settings . getAvatarId ( ) ) ;
}
let nick = APP . settings . getDisplayName ( ) ;
if ( config . useNicks && ! nick ) {
nick = APP . UI . askForNickname ( ) ;
APP . settings . setDisplayName ( nick ) ;
}
nick && room . setDisplayName ( nick ) ;
}
/ * *
* Get user nickname by user id .
* @ param { string } id user id
* @ returns { string ? } user nickname or undefined if user is unknown .
* /
function getDisplayName ( id ) {
if ( APP . conference . isLocalId ( id ) ) {
return APP . settings . getDisplayName ( ) ;
}
const participant = getParticipantById ( APP . store . getState ( ) , id ) ;
let participant = room . getParticipantById ( id ) ;
if ( participant && participant . getDisplayName ( ) ) {
return participant . getDisplayName ( ) ;
}
return participant && participant . name ;
}
/ * *
@ -989,6 +964,13 @@ export default {
isConnectionInterrupted ( ) {
return this . _room . isConnectionInterrupted ( ) ;
} ,
/ * *
* Obtains the local display name .
* @ returns { string | undefined }
* /
getLocalDisplayName ( ) {
return getDisplayName ( this . getMyUserId ( ) ) ;
} ,
/ * *
* Finds JitsiParticipant for given id .
*
@ -1162,7 +1144,7 @@ export default {
this . _setLocalAudioVideoStreams ( localTracks ) ;
this . _room = room ; // FIXME do not use this
_setupLocalParticipantProperties ( ) ;
setLocalParticipantData ( room , APP . store . getState ( ) ) ;
this . _setupListeners ( ) ;
} ,
@ -2420,13 +2402,15 @@ export default {
* @ param email { string } the new email
* /
changeLocalEmail ( email = '' ) {
const localParticipant = getLocalParticipant ( APP . store . getState ( ) ) ;
email = String ( email ) . trim ( ) ;
if ( email === APP . settings . getEmail ( ) ) {
if ( email === localParticipant . email ) {
return ;
}
const localId = room ? room . myUserId ( ) : undefine d;
const localId = localParticipant . i d;
APP . store . dispatch ( participantUpdated ( {
id : localId ,
@ -2444,22 +2428,22 @@ export default {
* @ param url { string } the new url
* /
changeLocalAvatarUrl ( url = '' ) {
const { avatarURL , id } = getLocalParticipant ( APP . store . getState ( ) ) ;
url = String ( url ) . trim ( ) ;
if ( url === APP . settings . getAvatarUrl ( ) ) {
if ( url === avatarURL ) {
return ;
}
const localId = room ? room . myUserId ( ) : undefined ;
APP . store . dispatch ( participantUpdated ( {
id : localId ,
id ,
local : true ,
avatarURL : url
} ) ) ;
APP . settings . setAvatarUrl ( url ) ;
APP . UI . setUserAvatarUrl ( localI d, url ) ;
APP . UI . setUserAvatarUrl ( i d, url ) ;
sendData ( commands . AVATAR _URL , url ) ;
} ,
@ -2501,13 +2485,14 @@ export default {
changeLocalDisplayName ( nickname = '' ) {
const formattedNickname
= nickname . trim ( ) . substr ( 0 , MAX _DISPLAY _NAME _LENGTH ) ;
const { id , name } = getLocalParticipant ( APP . store . getState ( ) ) ;
if ( formattedNickname === APP . settings . getDisplayN ame( ) ) {
if ( formattedNickname === n ame) {
return ;
}
APP . store . dispatch ( participantUpdated ( {
id : this . getMyUserId ( ) ,
id ,
local : true ,
name : formattedNickname
} ) ) ;
@ -2515,7 +2500,7 @@ export default {
APP . settings . setDisplayName ( formattedNickname ) ;
if ( room ) {
room . setDisplayName ( formattedNickname ) ;
APP . UI . changeDisplayName ( this . getMyUserId ( ) , formattedNickname ) ;
APP . UI . changeDisplayName ( id , formattedNickname ) ;
}
} ,