diff --git a/react/features/base/avatar/components/Avatar.js b/react/features/base/avatar/components/Avatar.js index 7ba5c6879..9c36a61cf 100644 --- a/react/features/base/avatar/components/Avatar.js +++ b/react/features/base/avatar/components/Avatar.js @@ -175,15 +175,14 @@ class Avatar extends PureComponent { * @returns {Props} */ export function _mapStateToProps(state: Object, ownProps: Props) { - const { colorBase, displayName, participantId, url } = ownProps; + const { colorBase, displayName, participantId } = ownProps; const _participant = participantId && getParticipantById(state, participantId); const _initialsBase = (_participant && _participant.name) || displayName; return { _initialsBase, _loadableAvatarUrl: _participant && _participant.loadableAvatarUrl, - colorBase: !colorBase && _participant ? _participant.id : colorBase, - url: !url && _participant && _participant.isJigasi ? 'icon://phone' : url + colorBase: !colorBase && _participant ? _participant.id : colorBase }; } diff --git a/react/features/base/participants/constants.js b/react/features/base/participants/constants.js index 0271caa17..34319d219 100644 --- a/react/features/base/participants/constants.js +++ b/react/features/base/participants/constants.js @@ -13,6 +13,13 @@ */ export const DEFAULT_AVATAR_RELATIVE_PATH = 'images/avatar.png'; +/** + * Icon URL for jigasi participants. + * + * @type {string} + */ +export const JIGASI_PARTICIPANT_ICON = 'icon://phone'; + /** * The local participant might not have real ID until she joins a conference, * so use 'local' as her default ID. diff --git a/react/features/base/participants/functions.js b/react/features/base/participants/functions.js index cc070d354..e5dd605d0 100644 --- a/react/features/base/participants/functions.js +++ b/react/features/base/participants/functions.js @@ -9,6 +9,7 @@ import { getTrackByMediaTypeAndParticipant } from '../tracks'; import { createDeferred } from '../util'; import { + JIGASI_PARTICIPANT_ICON, MAX_DISPLAY_NAME_LENGTH, PARTICIPANT_ROLE } from './constants'; @@ -24,6 +25,9 @@ const AVATAR_QUEUE = []; const AVATAR_CHECKED_URLS = new Map(); /* eslint-disable arrow-body-style */ const AVATAR_CHECKER_FUNCTIONS = [ + participant => { + return participant && participant.isJigasi ? JIGASI_PARTICIPANT_ICON : null; + }, participant => { return participant && participant.avatarURL ? participant.avatarURL : null; }, @@ -257,6 +261,16 @@ export function isEveryoneModerator(stateful: Object | Function) { return true; } +/** + * Checks a URL string and returns true if it's an icon url. + * + * @param {string?} url - The URL string to check. + * @returns {boolean} + */ +export function isIconUrl(url: ?string) { + return Boolean(url && url.match(/icon:\/\/(.+)/i)); +} + /** * Returns true if the current local participant is a moderator in the * conference. diff --git a/react/features/base/participants/preloadImage.native.js b/react/features/base/participants/preloadImage.native.js index 0a35e9963..4cd2683a2 100644 --- a/react/features/base/participants/preloadImage.native.js +++ b/react/features/base/participants/preloadImage.native.js @@ -3,6 +3,8 @@ import { Image } from 'react-native'; +import { isIconUrl } from './functions'; + /** * Tries to preload an image. * @@ -10,6 +12,10 @@ import { Image } from 'react-native'; * @returns {Promise} */ export function preloadImage(src: string): Promise { + if (isIconUrl(src)) { + return Promise.resolve(src); + } + return new Promise((resolve, reject) => { Image.prefetch(src).then(() => resolve(src), reject); }); diff --git a/react/features/base/participants/preloadImage.web.js b/react/features/base/participants/preloadImage.web.js index f0848516f..c4b6fcc40 100644 --- a/react/features/base/participants/preloadImage.web.js +++ b/react/features/base/participants/preloadImage.web.js @@ -1,6 +1,8 @@ // @flow +import { isIconUrl } from './functions'; + declare var config: Object; /** @@ -10,6 +12,10 @@ declare var config: Object; * @returns {Promise} */ export function preloadImage(src: string): Promise { + if (isIconUrl(src)) { + return Promise.resolve(src); + } + if (typeof config === 'object' && config.disableThirdPartyRequests) { return Promise.reject(); }