|
@@ -1,8 +1,5 @@
|
1
|
1
|
// @flow
|
2
|
|
-import {
|
3
|
|
- getAvatarURL as _getAvatarURL,
|
4
|
|
- getGravatarURL
|
5
|
|
-} from 'js-utils/avatar';
|
|
2
|
+import { getGravatarURL } from 'js-utils/avatar';
|
6
|
3
|
|
7
|
4
|
import { toState } from '../redux';
|
8
|
5
|
|
|
@@ -12,8 +9,6 @@ import { getTrackByMediaTypeAndParticipant } from '../tracks';
|
12
|
9
|
import { createDeferred } from '../util';
|
13
|
10
|
|
14
|
11
|
import {
|
15
|
|
- DEFAULT_AVATAR_RELATIVE_PATH,
|
16
|
|
- LOCAL_PARTICIPANT_DEFAULT_ID,
|
17
|
12
|
MAX_DISPLAY_NAME_LENGTH,
|
18
|
13
|
PARTICIPANT_ROLE
|
19
|
14
|
} from './constants';
|
|
@@ -38,73 +33,6 @@ const AVATAR_CHECKER_FUNCTIONS = [
|
38
|
33
|
];
|
39
|
34
|
/* eslint-enable arrow-body-style */
|
40
|
35
|
|
41
|
|
-/**
|
42
|
|
- * Returns the URL of the image for the avatar of a specific participant.
|
43
|
|
- *
|
44
|
|
- * @param {Participant} [participant] - The participant to return the avatar URL
|
45
|
|
- * of.
|
46
|
|
- * @param {string} [participant.avatarID] - Participant's avatar ID.
|
47
|
|
- * @param {string} [participant.avatarURL] - Participant's avatar URL.
|
48
|
|
- * @param {string} [participant.email] - Participant's e-mail address.
|
49
|
|
- * @param {string} [participant.id] - Participant's ID.
|
50
|
|
- * @public
|
51
|
|
- * @returns {string} The URL of the image for the avatar of the specified
|
52
|
|
- * participant.
|
53
|
|
- */
|
54
|
|
-export function getAvatarURL({ avatarID, avatarURL, email, id }: {
|
55
|
|
- avatarID: string,
|
56
|
|
- avatarURL: string,
|
57
|
|
- email: string,
|
58
|
|
- id: string
|
59
|
|
-}) {
|
60
|
|
- // If disableThirdPartyRequests disables third-party avatar services, we are
|
61
|
|
- // restricted to a stock image of ours.
|
62
|
|
- if (typeof config === 'object' && config.disableThirdPartyRequests) {
|
63
|
|
- return DEFAULT_AVATAR_RELATIVE_PATH;
|
64
|
|
- }
|
65
|
|
-
|
66
|
|
- // If an avatarURL is specified, then obviously there's nothing to generate.
|
67
|
|
- if (avatarURL) {
|
68
|
|
- return avatarURL;
|
69
|
|
- }
|
70
|
|
-
|
71
|
|
- // The deployment is allowed to choose the avatar service which is to
|
72
|
|
- // generate the random avatars.
|
73
|
|
- const avatarService
|
74
|
|
- = typeof interfaceConfig === 'object'
|
75
|
|
- && interfaceConfig.RANDOM_AVATAR_URL_PREFIX
|
76
|
|
- ? {
|
77
|
|
- urlPrefix: interfaceConfig.RANDOM_AVATAR_URL_PREFIX,
|
78
|
|
- urlSuffix: interfaceConfig.RANDOM_AVATAR_URL_SUFFIX }
|
79
|
|
- : undefined;
|
80
|
|
-
|
81
|
|
- // eslint-disable-next-line object-property-newline
|
82
|
|
- return _getAvatarURL({ avatarID, email, id }, avatarService);
|
83
|
|
-}
|
84
|
|
-
|
85
|
|
-/**
|
86
|
|
- * Returns the avatarURL for the participant associated with the passed in
|
87
|
|
- * participant ID.
|
88
|
|
- *
|
89
|
|
- * @param {(Function|Object|Participant[])} stateful - The redux state
|
90
|
|
- * features/base/participants, the (whole) redux state, or redux's
|
91
|
|
- * {@code getState} function to be used to retrieve the state
|
92
|
|
- * features/base/participants.
|
93
|
|
- * @param {string} id - The ID of the participant to retrieve.
|
94
|
|
- * @param {boolean} isLocal - An optional parameter indicating whether or not
|
95
|
|
- * the partcipant id is for the local user. If true, a different logic flow is
|
96
|
|
- * used find the local user, ignoring the id value as it can change through the
|
97
|
|
- * beginning and end of a call.
|
98
|
|
- * @returns {(string|undefined)}
|
99
|
|
- */
|
100
|
|
-export function getAvatarURLByParticipantId(
|
101
|
|
- stateful: Object | Function,
|
102
|
|
- id: string = LOCAL_PARTICIPANT_DEFAULT_ID) {
|
103
|
|
- const participant = getParticipantById(stateful, id);
|
104
|
|
-
|
105
|
|
- return participant && getAvatarURL(participant);
|
106
|
|
-}
|
107
|
|
-
|
108
|
36
|
/**
|
109
|
37
|
* Resolves the first loadable avatar URL for a participant.
|
110
|
38
|
*
|