aot: jigasi participant icon
This commit is contained in:
parent
cbc7e1b6be
commit
ad7892ebce
|
@ -175,15 +175,14 @@ class Avatar<P: Props> extends PureComponent<P, State> {
|
||||||
* @returns {Props}
|
* @returns {Props}
|
||||||
*/
|
*/
|
||||||
export function _mapStateToProps(state: Object, ownProps: 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 _participant = participantId && getParticipantById(state, participantId);
|
||||||
const _initialsBase = (_participant && _participant.name) || displayName;
|
const _initialsBase = (_participant && _participant.name) || displayName;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
_initialsBase,
|
_initialsBase,
|
||||||
_loadableAvatarUrl: _participant && _participant.loadableAvatarUrl,
|
_loadableAvatarUrl: _participant && _participant.loadableAvatarUrl,
|
||||||
colorBase: !colorBase && _participant ? _participant.id : colorBase,
|
colorBase: !colorBase && _participant ? _participant.id : colorBase
|
||||||
url: !url && _participant && _participant.isJigasi ? 'icon://phone' : url
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,13 @@
|
||||||
*/
|
*/
|
||||||
export const DEFAULT_AVATAR_RELATIVE_PATH = 'images/avatar.png';
|
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,
|
* The local participant might not have real ID until she joins a conference,
|
||||||
* so use 'local' as her default ID.
|
* so use 'local' as her default ID.
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { getTrackByMediaTypeAndParticipant } from '../tracks';
|
||||||
import { createDeferred } from '../util';
|
import { createDeferred } from '../util';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
JIGASI_PARTICIPANT_ICON,
|
||||||
MAX_DISPLAY_NAME_LENGTH,
|
MAX_DISPLAY_NAME_LENGTH,
|
||||||
PARTICIPANT_ROLE
|
PARTICIPANT_ROLE
|
||||||
} from './constants';
|
} from './constants';
|
||||||
|
@ -24,6 +25,9 @@ const AVATAR_QUEUE = [];
|
||||||
const AVATAR_CHECKED_URLS = new Map();
|
const AVATAR_CHECKED_URLS = new Map();
|
||||||
/* eslint-disable arrow-body-style */
|
/* eslint-disable arrow-body-style */
|
||||||
const AVATAR_CHECKER_FUNCTIONS = [
|
const AVATAR_CHECKER_FUNCTIONS = [
|
||||||
|
participant => {
|
||||||
|
return participant && participant.isJigasi ? JIGASI_PARTICIPANT_ICON : null;
|
||||||
|
},
|
||||||
participant => {
|
participant => {
|
||||||
return participant && participant.avatarURL ? participant.avatarURL : null;
|
return participant && participant.avatarURL ? participant.avatarURL : null;
|
||||||
},
|
},
|
||||||
|
@ -257,6 +261,16 @@ export function isEveryoneModerator(stateful: Object | Function) {
|
||||||
return true;
|
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
|
* Returns true if the current local participant is a moderator in the
|
||||||
* conference.
|
* conference.
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
import { Image } from 'react-native';
|
import { Image } from 'react-native';
|
||||||
|
|
||||||
|
import { isIconUrl } from './functions';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to preload an image.
|
* Tries to preload an image.
|
||||||
*
|
*
|
||||||
|
@ -10,6 +12,10 @@ import { Image } from 'react-native';
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
export function preloadImage(src: string): Promise<string> {
|
export function preloadImage(src: string): Promise<string> {
|
||||||
|
if (isIconUrl(src)) {
|
||||||
|
return Promise.resolve(src);
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
Image.prefetch(src).then(() => resolve(src), reject);
|
Image.prefetch(src).then(() => resolve(src), reject);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
|
import { isIconUrl } from './functions';
|
||||||
|
|
||||||
declare var config: Object;
|
declare var config: Object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,6 +12,10 @@ declare var config: Object;
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
export function preloadImage(src: string): Promise<string> {
|
export function preloadImage(src: string): Promise<string> {
|
||||||
|
if (isIconUrl(src)) {
|
||||||
|
return Promise.resolve(src);
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof config === 'object' && config.disableThirdPartyRequests) {
|
if (typeof config === 'object' && config.disableThirdPartyRequests) {
|
||||||
return Promise.reject();
|
return Promise.reject();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue