communication-react-19
Version:
React library for building modern communication user experiences utilizing Azure Communication Services (React 19 compatible fork)
51 lines • 2.39 kB
JavaScript
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { getIdentifierKind } from '@azure/communication-common';
import { fromFlatCommunicationIdentifier, memoizeFnAll } from "../../../acs-ui-common/src";
import { toFlatCommunicationIdentifier } from "../../../acs-ui-common/src";
import memoizeOne from 'memoize-one';
const convertRemoteParticipantToParticipantListParticipant = (userId, displayName, state, isMuted, isScreenSharing, isSpeaking, raisedHand, localUserCanRemoveOthers, reaction, spotlight, mediaAccess) => {
const identifier = fromFlatCommunicationIdentifier(userId);
return {
userId,
displayName,
state,
isMuted,
isScreenSharing,
isSpeaking,
raisedHand,
// ACS users can not remove Teams users.
// Removing unknown types of users is undefined.
isRemovable: (getIdentifierKind(identifier).kind === 'communicationUser' ||
getIdentifierKind(identifier).kind === 'phoneNumber') &&
localUserCanRemoveOthers,
reaction,
spotlight,
mediaAccess
};
};
/**
* @private
*/
export const memoizedConvertAllremoteParticipants = memoizeFnAll((userId, displayName, state, isMuted, isScreenSharing, isSpeaking, raisedHand, localUserCanRemoveOthers, reaction, spotlight, mediaAccess) => {
return convertRemoteParticipantToParticipantListParticipant(userId, displayName, state, isMuted, isScreenSharing, isSpeaking, raisedHand, localUserCanRemoveOthers, reaction, spotlight, mediaAccess);
});
/**
* @private
*/
export const memoizedConvertToVideoTileReaction = memoizeOne((reactionState) => {
return reactionState && reactionState.reactionMessage
? {
reactionType: reactionState.reactionMessage.reactionType,
receivedOn: reactionState.receivedOn
}
: undefined;
});
/**
* @private
*/
export const memoizedSpotlight = memoizeOne((spotlightedParticipants, userId) => {
const spotlightOrder = spotlightedParticipants === null || spotlightedParticipants === void 0 ? void 0 : spotlightedParticipants.find((spotlightedParticipant) => toFlatCommunicationIdentifier(spotlightedParticipant.identifier) === userId);
return spotlightOrder ? { spotlightedOrderPosition: spotlightOrder.order } : undefined;
});
//# sourceMappingURL=participantListSelectorUtils.js.map