aot: jigasi participant icon

This commit is contained in:
Bettenbuk Zoltan 2019-07-16 11:23:01 +01:00 committed by Zoltan Bettenbuk
parent cbc7e1b6be
commit ad7892ebce
5 changed files with 35 additions and 3 deletions

View File

@ -175,15 +175,14 @@ class Avatar<P: Props> extends PureComponent<P, State> {
* @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
};
}

View File

@ -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.

View File

@ -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.

View File

@ -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<string> {
if (isIconUrl(src)) {
return Promise.resolve(src);
}
return new Promise((resolve, reject) => {
Image.prefetch(src).then(() => resolve(src), reject);
});

View File

@ -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<string> {
if (isIconUrl(src)) {
return Promise.resolve(src);
}
if (typeof config === 'object' && config.disableThirdPartyRequests) {
return Promise.reject();
}