Skip to content

Commit a1468d3

Browse files
[bugfix] Add adapter options to CallComposite.js files (#4486)
* add adapter options to JS bundles * Change files * fix cc in app * stabilize bot name callback * remove console * fix beta build
1 parent 39e8218 commit a1468d3

12 files changed

Lines changed: 58 additions & 15 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "Add Adapter options to JS bundles to allow for custom bot displayNames",
5+
"comment": "add adapter options to JS bundles",
6+
"packageName": "@azure/communication-react",
7+
"email": "dmceachern@microsoft.com",
8+
"dependentChangeType": "patch"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "Add Adapter options to JS bundles to allow for custom bot displayNames",
5+
"comment": "add adapter options to JS bundles",
6+
"packageName": "@azure/communication-react",
7+
"email": "dmceachern@microsoft.com",
8+
"dependentChangeType": "patch"
9+
}

packages/communication-react/review/beta/communication-react.api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3508,7 +3508,7 @@ export interface NetworkDiagnosticsState {
35083508
latest: LatestNetworkDiagnostics;
35093509
}
35103510

3511-
// @beta
3511+
// @public
35123512
export type OnFetchProfileCallback = (userId: string, defaultProfile?: Profile) => Promise<Profile | undefined>;
35133513

35143514
// @public
@@ -3721,7 +3721,7 @@ export interface PPTLiveCallFeatureState {
37213721
isActive: boolean;
37223722
}
37233723

3724-
// @beta
3724+
// @public
37253725
export type Profile = {
37263726
displayName?: string;
37273727
};

packages/communication-react/review/stable/communication-react.api.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,7 @@ export type CommonCallAdapterOptions = {
16061606
videoBackgroundImages?: VideoBackgroundImage[];
16071607
onResolveDependency?: () => Promise<VideoBackgroundEffectsDependency>;
16081608
};
1609+
onFetchProfile?: OnFetchProfileCallback;
16091610
callingSounds?: CallingSounds;
16101611
reactionResources?: ReactionResources;
16111612
};
@@ -2931,6 +2932,9 @@ export interface NetworkDiagnosticsState {
29312932
latest: LatestNetworkDiagnostics;
29322933
}
29332934

2935+
// @public
2936+
export type OnFetchProfileCallback = (userId: string, defaultProfile?: Profile) => Promise<Profile | undefined>;
2937+
29342938
// @public
29352939
export type OnRenderAvatarCallback = (
29362940
userId?: string, options?: CustomAvatarOptions,
@@ -3129,6 +3133,11 @@ export interface PPTLiveCallFeatureState {
31293133
isActive: boolean;
31303134
}
31313135

3136+
// @public
3137+
export type Profile = {
3138+
displayName?: string;
3139+
};
3140+
31323141
// @public
31333142
export type RaisedHand = {
31343143
raisedHandOrderPosition: number;

packages/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,6 @@ export type CommonCallAdapterOptions = {
13971397
videoBackgroundImages?: VideoBackgroundImage[];
13981398
onResolveDependency?: () => Promise<VideoBackgroundEffectsDependency>;
13991399
};
1400-
/* @conditional-compile-remove(teams-identity-support) */
14011400
/**
14021401
* Use this to fetch profile information which will override data in {@link CallAdapterState} like display name
14031402
* The onFetchProfile is fetch-and-forget one time action for each user, once a user profile is updated, the value will be cached

packages/react-composites/src/composites/CallComposite/adapter/OnFetchProfileCallback.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ import { AdapterStateModifier } from './AzureCommunicationCallAdapter';
77
import { createParticipantModifier } from '../utils';
88

99
/**
10-
* Callback function used to provide custom data to build profile for a user.
10+
* Callback function used to provide custom data to build profile for a user or bot.
1111
*
12-
* @beta
12+
* @public
1313
*/
1414
export type OnFetchProfileCallback = (userId: string, defaultProfile?: Profile) => Promise<Profile | undefined>;
1515

1616
/**
17-
* The profile of a user.
17+
* The profile of a user or bot.
1818
*
19-
* @beta
19+
* @public
2020
*/
2121
export type Profile = {
2222
/**

packages/react-composites/src/composites/CallComposite/adapter/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export {
1818
export type { TeamsAdapterOptions } from './AzureCommunicationCallAdapter';
1919
/* @conditional-compile-remove(teams-identity-support) */
2020
export type { TeamsCallAdapterArgs } from './AzureCommunicationCallAdapter';
21-
/* @conditional-compile-remove(teams-identity-support) */
21+
2222
export type { OnFetchProfileCallback, Profile } from './OnFetchProfileCallback';
2323
export type {
2424
AzureCommunicationCallAdapterArgs,

packages/react-composites/src/composites/CallComposite/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export { createTeamsCallAdapter, createTeamsCallAdapterFromClient, useTeamsCallA
2222
export type { TeamsAdapterOptions } from './adapter';
2323

2424
/* @conditional-compile-remove(teams-identity-support) */
25-
export type { TeamsCallAdapter, TeamsCallAdapterArgs, Profile, OnFetchProfileCallback } from './adapter';
25+
export type { TeamsCallAdapter, TeamsCallAdapterArgs } from './adapter';
26+
export type { Profile, OnFetchProfileCallback } from './adapter';
2627

2728
export type {
2829
AzureCommunicationCallAdapterArgs,

samples/Calling/src/app/views/CallScreen.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { useTeamsCallAdapter, TeamsCallAdapter } from '@azure/communication-reac
1919

2020
import { onResolveVideoEffectDependencyLazy } from '@azure/communication-react';
2121
/* @conditional-compile-remove(teams-identity-support) */
22-
import type { TeamsAdapterOptions } from '@azure/communication-react';
22+
import type { Profile, TeamsAdapterOptions } from '@azure/communication-react';
2323
import type { StartCallIdentifier } from '@azure/communication-react';
2424
import React, { useCallback, useMemo, useRef } from 'react';
2525
import { createAutoRefreshingCredential } from '../utils/credential';
@@ -209,6 +209,13 @@ const AzureCommunicationOutboundCallScreen = (props: AzureCommunicationCallScree
209209
laughReaction: { url: '/assets/reactions/laughEmoji.png', frameCount: 102 },
210210
applauseReaction: { url: '/assets/reactions/clapEmoji.png', frameCount: 102 },
211211
surprisedReaction: { url: '/assets/reactions/surprisedEmoji.png', frameCount: 102 }
212+
},
213+
/* @conditional-compile-remove(teams-identity-support) */
214+
onFetchProfile: async (userId: string, defaultProfile?: Profile): Promise<Profile | undefined> => {
215+
if (userId === '<28:orgid:Enter your teams app here>') {
216+
return { displayName: 'Teams app display name' };
217+
}
218+
return defaultProfile;
212219
}
213220
};
214221
}, []);

samples/StaticHtmlComposites/outboundCallComposite.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@
3030
userId: user,
3131
token: token,
3232
displayName: displayName,
33-
targetCallees: [{ teamsAppId: '<Enter your teams app id>', cloud: 'public' }] // Provide the identifier you want to call, can be flat as a string.
33+
targetCallees: [{ teamsAppId: '<Enter your teams app id here>', cloud: 'public' }], // Provide the identifier you want to call, can be flat as a string.
34+
options: {
35+
onFetchProfile: async (userId) => {
36+
if (userId === '<28:orgid:Enter your teams bot name here>') {
37+
return { displayName: 'displayName' };
38+
}
39+
}
40+
}
3441
},
3542
document.getElementById('outbound-call-composite-container')
3643
);

0 commit comments

Comments
 (0)