rn,welcome: fix accessing local participant

It need not always exist, since it's created asynchronousluy on app
initiualization. Make sure we are ready for it.

I've seen backtraces because of this.
This commit is contained in:
Saúl Ibarra Corretgé 2019-08-23 15:24:29 +02:00 committed by Saúl Ibarra Corretgé
parent 02e058370e
commit e0815de2ad
1 changed files with 6 additions and 4 deletions

View File

@ -44,12 +44,12 @@ type Props = {
/**
* Display name of the local participant.
*/
_displayName: string,
_displayName: ?string,
/**
* ID of the local participant.
*/
_localParticipantId: string,
_localParticipantId: ?string,
/**
* Sets the side bar visible or hidden.
@ -157,10 +157,12 @@ class WelcomePageSideBar extends Component<Props> {
*/
function _mapStateToProps(state: Object) {
const _localParticipant = getLocalParticipant(state);
const _localParticipantId = _localParticipant?.id;
const _displayName = _localParticipant && getParticipantDisplayName(state, _localParticipantId);
return {
_displayName: getParticipantDisplayName(state, _localParticipant.id),
_localParticipantId: _localParticipant.id,
_displayName,
_localParticipantId,
_visible: state['features/welcome'].sideBarVisible
};
}