瀏覽代碼

avatar: make code a bit clearer

Uses nullish coalescing and optional chaining.
master
Saúl Ibarra Corretgé 6 年之前
父節點
當前提交
69c21cbb11
共有 1 個檔案被更改,包括 3 行新增3 行删除
  1. 3
    3
      react/features/base/avatar/components/Avatar.js

+ 3
- 3
react/features/base/avatar/components/Avatar.js 查看文件

176
  */
176
  */
177
 export function _mapStateToProps(state: Object, ownProps: Props) {
177
 export function _mapStateToProps(state: Object, ownProps: Props) {
178
     const { colorBase, displayName, participantId } = ownProps;
178
     const { colorBase, displayName, participantId } = ownProps;
179
-    const _participant = participantId && getParticipantById(state, participantId);
180
-    const _initialsBase = (_participant && _participant.name) || displayName;
179
+    const _participant: ?Object = participantId && getParticipantById(state, participantId);
180
+    const _initialsBase = _participant?.name ?? displayName;
181
     const screenShares = state['features/video-layout'].screenShares || [];
181
     const screenShares = state['features/video-layout'].screenShares || [];
182
 
182
 
183
-    let _loadableAvatarUrl = _participant && _participant.loadableAvatarUrl;
183
+    let _loadableAvatarUrl = _participant?.loadableAvatarUrl;
184
 
184
 
185
     if (participantId && screenShares.includes(participantId)) {
185
     if (participantId && screenShares.includes(participantId)) {
186
         _loadableAvatarUrl = 'icon://share-desktop';
186
         _loadableAvatarUrl = 'icon://share-desktop';

Loading…
取消
儲存