avatar: make code a bit clearer

Uses nullish coalescing and optional chaining.
This commit is contained in:
Saúl Ibarra Corretgé 2019-08-14 14:26:46 +02:00 committed by Saúl Ibarra Corretgé
parent abefc56750
commit 69c21cbb11
1 changed files with 3 additions and 3 deletions

View File

@ -176,11 +176,11 @@ class Avatar<P: Props> extends PureComponent<P, State> {
*/
export function _mapStateToProps(state: Object, ownProps: Props) {
const { colorBase, displayName, participantId } = ownProps;
const _participant = participantId && getParticipantById(state, participantId);
const _initialsBase = (_participant && _participant.name) || displayName;
const _participant: ?Object = participantId && getParticipantById(state, participantId);
const _initialsBase = _participant?.name ?? displayName;
const screenShares = state['features/video-layout'].screenShares || [];
let _loadableAvatarUrl = _participant && _participant.loadableAvatarUrl;
let _loadableAvatarUrl = _participant?.loadableAvatarUrl;
if (participantId && screenShares.includes(participantId)) {
_loadableAvatarUrl = 'icon://share-desktop';