浏览代码

Reduce duplication

j8
Lyubo Marinov 8 年前
父节点
当前提交
c1fbbc4571

+ 6
- 4
react/features/base/participants/components/Avatar.native.js 查看文件

5
 import { Platform } from '../../react';
5
 import { Platform } from '../../react';
6
 import { ColorPalette } from '../../styles';
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
  * The default image/source to be used in case none is specified or the
9
  * The default image/source to be used in case none is specified or the
14
  * specified one fails to load.
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
  * @private
18
  * @private
17
  * @type {string}
19
  * @type {string}
18
  */
20
  */

+ 15
- 0
react/features/base/participants/constants.js 查看文件

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
  * Local participant might not have real ID until he joins a conference,
17
  * Local participant might not have real ID until he joins a conference,
3
  * so use 'local' as its default ID.
18
  * so use 'local' as its default ID.

+ 3
- 1
react/features/base/participants/functions.js 查看文件

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

+ 4
- 3
react/features/toolbox/defaultToolbarButtons.js 查看文件

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

正在加载...
取消
保存