소스 검색

Reduce duplication

j8
Lyubo Marinov 7 년 전
부모
커밋
c1fbbc4571

+ 6
- 4
react/features/base/participants/components/Avatar.native.js 파일 보기

@@ -5,14 +5,16 @@ import { CachedImage, ImageCache } from 'react-native-img-cache';
5 5
 import { Platform } from '../../react';
6 6
 import { ColorPalette } from '../../styles';
7 7
 
8
-// FIXME @lyubomir: The string images/avatar2.png appears three times in our
9
-// source code at the time of this writing. Firstly, it presents a maintenance
10
-// obstacle which increases the risks of inconsistency. Secondly, it is
11
-// repulsive (when enlarged, especially, on mobile/React Native, for example).
12 8
 /**
13 9
  * The default image/source to be used in case none is specified or the
14 10
  * specified one fails to load.
15 11
  *
12
+ * XXX The relative path to the default/stock (image) file is defined by the
13
+ * <tt>const</tt> <tt>DEFAULT_AVATAR_RELATIVE_PATH</tt>. Unfortunately, the
14
+ * packager of React Native cannot deal with it early enough for the following
15
+ * <tt>require</tt> to succeed at runtime. Anyway, be sure to synchronize the
16
+ * relative path on Web and mobile for the purposes of consistency.
17
+ *
16 18
  * @private
17 19
  * @type {string}
18 20
  */

+ 15
- 0
react/features/base/participants/constants.js 파일 보기

@@ -1,3 +1,18 @@
1
+/**
2
+ * The relative path to the default/stock avatar (image) file used on both
3
+ * Web/React and mobile/React Native (for the purposes of consistency).
4
+ *
5
+ * XXX (1) Web/React utilizes relativity on the Jitsi Meet deployment.
6
+ * (2) Mobile/React Native utilizes relativity on the local file system at build
7
+ * time. Unfortunately, the packager of React Native cannot deal with the
8
+ * <tt>const</tt> early enough for <tt>require</tt> to succeed at runtime.
9
+ * Anyway, be sure to synchronize the relative path on Web and mobile for the
10
+ * purposes of consistency.
11
+ *
12
+ * @type {string}
13
+ */
14
+export const DEFAULT_AVATAR_RELATIVE_PATH = 'images/avatar.png';
15
+
1 16
 /**
2 17
  * Local participant might not have real ID until he joins a conference,
3 18
  * so use 'local' as its default ID.

+ 3
- 1
react/features/base/participants/functions.js 파일 보기

@@ -1,3 +1,5 @@
1
+import { DEFAULT_AVATAR_RELATIVE_PATH } from './constants';
2
+
1 3
 declare var config: Object;
2 4
 declare var interfaceConfig: Object;
3 5
 declare var MD5: Object;
@@ -20,7 +22,7 @@ export function getAvatarURL(participant) {
20 22
     // If disableThirdPartyRequests disables third-party avatar services, we are
21 23
     // restricted to a stock image of ours.
22 24
     if (typeof config === 'object' && config.disableThirdPartyRequests) {
23
-        return 'images/avatar.png';
25
+        return DEFAULT_AVATAR_RELATIVE_PATH;
24 26
     }
25 27
 
26 28
     const { avatarID, avatarURL, email, id } = participant;

+ 4
- 3
react/features/toolbox/defaultToolbarButtons.js 파일 보기

@@ -2,13 +2,14 @@
2 2
 
3 3
 import React from 'react';
4 4
 
5
+import { DEFAULT_AVATAR_RELATIVE_PATH } from '../base/participants';
5 6
 import { openDeviceSelectionDialog } from '../device-selection';
6 7
 import { openDialOutDialog } from '../dial-out';
7 8
 import { openAddPeopleDialog, openInviteDialog } from '../invite';
8
-import UIEvents from '../../../service/UI/UIEvents';
9
-
10 9
 import { VideoQualityButton } from '../video-quality';
11 10
 
11
+import UIEvents from '../../../service/UI/UIEvents';
12
+
12 13
 declare var APP: Object;
13 14
 declare var interfaceConfig: Object;
14 15
 declare var JitsiMeetJS: Object;
@@ -342,7 +343,7 @@ const buttons: Object = {
342 343
         enabled: true,
343 344
         html: <img
344 345
             id = 'avatar'
345
-            src = 'images/avatar.png' />,
346
+            src = { DEFAULT_AVATAR_RELATIVE_PATH } />,
346 347
         id: 'toolbar_button_profile',
347 348
         onClick() {
348 349
             JitsiMeetJS.analytics.sendEvent('toolbar.profile.toggled');

Loading…
취소
저장