Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
[RN] fix(Avatar): Match the implementation for web
hristoterezovd74e43ddcc97
diff --git a/conference.js b/conference.jsindex dc2d02dc83..94d3cef151 100644--- a/conference.js+++ b/conference.js@@ -21,9 +21,12 @@ import analytics from './modules/analytics/analytics';import EventEmitter from "events";import {- conferenceJoined,+ AVATAR_ID_COMMAND,+ AVATAR_URL_COMMAND,conferenceFailed,- conferenceLeft+ conferenceJoined,+ conferenceLeft,+ EMAIL_COMMAND} from './react/features/base/conference';import {isFatalJitsiConnectionError@@ -67,12 +70,12 @@ import {VIDEO_CONTAINER_TYPE} from "./modules/UI/videolayout/VideoContainer";* Known custom conference commands.*/const commands = {- EMAIL: "email",- AVATAR_URL: "avatar-url",- AVATAR_ID: "avatar-id",+ AVATAR_ID: AVATAR_ID_COMMAND,+ AVATAR_URL: AVATAR_URL_COMMAND,+ CUSTOM_ROLE: "custom-role",+ EMAIL: EMAIL_COMMAND,ETHERPAD: "etherpad",- SHARED_VIDEO: "shared-video",- CUSTOM_ROLE: "custom-role"+ SHARED_VIDEO: "shared-video"};/**diff --git a/modules/settings/Settings.js b/modules/settings/Settings.jsindex 4d8481a2f9..5f422c4899 100644--- a/modules/settings/Settings.js+++ b/modules/settings/Settings.js@@ -3,13 +3,7 @@ const logger = require("jitsi-meet-logger").getLogger(__filename);import UIUtil from '../UI/util/UIUtil';import jitsiLocalStorage from '../util/JitsiLocalStorage';--function generateUniqueId() {- function _p8() {- return (Math.random().toString(16) + "000000000").substr(2, 8);- }- return _p8() + _p8() + _p8() + _p8();-}+import { randomHexString } from '../../react/features/base/util';let avatarUrl = '';@@ -17,7 +11,7 @@ let email = UIUtil.unescapeHtml(jitsiLocalStorage.getItem("email") || '');let avatarId = UIUtil.unescapeHtml(jitsiLocalStorage.getItem("avatarId") || '');if (!avatarId) {// if there is no avatar id, we generate a unique one and use it forever- avatarId = generateUniqueId();+ avatarId = randomHexString(32);jitsiLocalStorage.setItem("avatarId", avatarId);}diff --git a/react/features/base/conference/actions.js b/react/features/base/conference/actions.jsindex 65d301f126..1b7b7f1f6b 100644--- a/react/features/base/conference/actions.js+++ b/react/features/base/conference/actions.js@@ -1,7 +1,10 @@import { JitsiConferenceEvents } from '../lib-jitsi-meet';import {+ changeParticipantAvatarID,+ changeParticipantAvatarURL,changeParticipantEmail,dominantSpeakerChanged,+ getLocalParticipant,participantJoined,participantLeft,participantRoleChanged@@ -18,7 +21,11 @@ import {SET_PASSWORD,SET_ROOM} from './actionTypes';-import { EMAIL_COMMAND } from './constants';+import {+ AVATAR_ID_COMMAND,+ AVATAR_URL_COMMAND,+ EMAIL_COMMAND+} from './constants';import { _addLocalTracksToConference } from './functions';/**@@ -69,11 +76,34 @@ function _addConferenceListeners(conference, dispatch) {JitsiConferenceEvents.USER_ROLE_CHANGED,(...args) => dispatch(participantRoleChanged(...args)));+ conference.addCommandListener(+ AVATAR_ID_COMMAND,+ (data, id) => dispatch(changeParticipantAvatarID(id, data.value)));+ conference.addCommandListener(+ AVATAR_URL_COMMAND,+ (data, id) => dispatch(changeParticipantAvatarURL(id, data.value)));conference.addCommandListener(EMAIL_COMMAND,(data, id) => dispatch(changeParticipantEmail(id, data.value)));}+/**+ * Sets the data for the local participant to the conference.+ *+ * @param {JitsiConference} conference - The JitsiConference instance.+ * @param {Object} state - The Redux state.+ * @returns {void}+ */+function _setLocalParticipantData(conference, state) {+ const localParticipant+ = getLocalParticipant(state['features/base/participants']);++ conference.removeCommand(AVATAR_ID_COMMAND);+ conference.sendCommand(AVATAR_ID_COMMAND, {+ value: localParticipant.avatarID+ });+}+/*** Signals that a specific conference has failed.*@@ -217,6 +247,8 @@ export function createConference() {_addConferenceListeners(conference, dispatch);+ _setLocalParticipantData(conference, state);+conference.join(password);};}diff --git a/react/features/base/conference/constants.js b/react/features/base/conference/constants.jsindex dfb348322d..035a99cd98 100644--- a/react/features/base/conference/constants.js+++ b/react/features/base/conference/constants.js@@ -1,5 +1,19 @@/**- * The command type for updating a participant's email address.+ * The command type for updating a participant's avatar ID.+ *+ * @type {string}+ */+export const AVATAR_ID_COMMAND = 'avatar-id';++/**+ * The command type for updating a participant's avatar URL.+ *+ * @type {string}+ */+export const AVATAR_URL_COMMAND = 'avatar-url';++/**+ * The command type for updating a participant's e-mail address.** @type {string}*/diff --git a/react/features/base/conference/index.js b/react/features/base/conference/index.jsindex 969667b3a4..39f1ee456a 100644--- a/react/features/base/conference/index.js+++ b/react/features/base/conference/index.js@@ -1,5 +1,6 @@export * from './actions';export * from './actionTypes';+export * from './constants';export * from './functions';import './middleware';diff --git a/react/features/base/participants/components/ParticipantView.native.js b/react/features/base/participants/components/ParticipantView.native.jsindex 49835fff7c..2deced2c84 100644--- a/react/features/base/participants/components/ParticipantView.native.js+++ b/react/features/base/participants/components/ParticipantView.native.js@@ -10,7 +10,7 @@ import { Container } from '../../react';import { getTrackByMediaTypeAndParticipant } from '../../tracks';import Avatar from './Avatar';-import { getParticipantById } from '../functions';+import { getAvatarURL, getParticipantById } from '../functions';import { styles } from './styles';/**@@ -162,14 +162,14 @@ function _toBoolean(value, undefinedValue) {* }}*/function _mapStateToProps(state, ownProps) {- const participantId = ownProps.participantId;- const participant- = getParticipantById(- state['features/base/participants'],- participantId);+ const { participantId } = ownProps;return {- _avatar: participant ? participant.avatar : undefined,+ _avatar:+ getAvatarURL(+ getParticipantById(+ state['features/base/participants'],+ participantId)),_videoTrack:getTrackByMediaTypeAndParticipant(state['features/base/tracks'],diff --git a/react/features/base/participants/functions.js b/react/features/base/participants/functions.jsindex 28e85a2ff2..75dadf59d8 100644--- a/react/features/base/participants/functions.js+++ b/react/features/base/participants/functions.js@@ -44,6 +44,9 @@ export function getAvatarURL(participant) {// from a configured avatar service).if (!key) {key = id;+ if (!key) {+ return undefined;+ }}// The deployment is allowed to choose the avatar service which is todiff --git a/react/features/base/participants/reducer.js b/react/features/base/participants/reducer.jsindex 8878bc6388..946db688c8 100644--- a/react/features/base/participants/reducer.js+++ b/react/features/base/participants/reducer.js@@ -1,4 +1,5 @@import { ReducerRegistry, setStateProperty } from '../redux';+import { randomHexString } from '../util';import {DOMINANT_SPEAKER_CHANGED,@@ -12,7 +13,6 @@ import {LOCAL_PARTICIPANT_DEFAULT_ID,PARTICIPANT_ROLE} from './constants';-import { getAvatarURL } from './functions';/*** Participant object.@@ -62,25 +62,25 @@ function _participant(state, action) {case PARTICIPANT_ID_CHANGED:if (state.id === action.oldValue) {- const id = action.newValue;- const newState = {+ return {...state,- id+ id: action.newValue};-- if (!newState.avatar) {- newState.avatar = getAvatarURL(newState);- }-- return newState;}break;case PARTICIPANT_JOINED: {const participant = action.participant; // eslint-disable-line no-shadow- const { avatar, dominantSpeaker, email, local, pinned, role }+ const { avatarURL, dominantSpeaker, email, local, pinned, role }= participant;- let { id, name } = participant;+ let { avatarID, id, name } = participant;++ // avatarID+ //+ // TODO Get the avatarID of the local participant from localStorage.+ if (!avatarID && local) {+ avatarID = randomHexString(32);+ }// id//@@ -97,8 +97,9 @@ function _participant(state, action) {name = local ? 'me' : 'Fellow Jitster';}- const newState = {- avatar,+ return {+ avatarID,+ avatarURL,dominantSpeaker: dominantSpeaker || false,email,id,@@ -107,12 +108,6 @@ function _participant(state, action) {pinned: pinned || false,role: role || PARTICIPANT_ROLE.NONE};-- if (!newState.avatar) {- newState.avatar = getAvatarURL(newState);- }-- return newState;}case PARTICIPANT_UPDATED: {@@ -130,10 +125,6 @@ function _participant(state, action) {}}- if (!newState.avatar) {- newState.avatar = getAvatarURL(newState);- }-return newState;}break;