Skip to content

Commit

Permalink
Update createAzureCommunicationCallAdapter ctor to take an object i…
Browse files Browse the repository at this point in the history
…nstead of many params (#625)
  • Loading branch information
JamesBurnside authored Aug 3, 2021
1 parent 2f442fd commit f16a14c
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 61 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Update createAzureCommunicationCallAdapter constructor to take in a named object instead of seperate args",
"packageName": "@internal/react-composites",
"email": "[email protected]",
"dependentChangeType": "patch"
}
11 changes: 10 additions & 1 deletion packages/communication-react/review/communication-react.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ export class AzureCommunicationCallAdapter implements CallAdapter {
unmute(): Promise<void>;
}

// @public (undocumented)
export type AzureCommunicationCallAdapterArgs = {
userId: CommunicationUserKind;
displayName: string;
credential: CommunicationTokenCredential;
locator: TeamsMeetingLinkLocator | GroupCallLocator;
callClientOptions?: CallClientOptions;
};

// @public
export interface BaseCustomStylesProps {
root?: IStyle;
Expand Down Expand Up @@ -739,7 +748,7 @@ export interface ControlBarProps {
}

// @public (undocumented)
export const createAzureCommunicationCallAdapter: (userId: CommunicationUserKind, displayName: string, credential: CommunicationTokenCredential, locator: TeamsMeetingLinkLocator | GroupCallLocator, callClientOptions?: CallClientOptions | undefined) => Promise<CallAdapter>;
export const createAzureCommunicationCallAdapter: ({ userId, displayName, credential, locator, callClientOptions }: AzureCommunicationCallAdapterArgs) => Promise<CallAdapter>;

// @public (undocumented)
export const createAzureCommunicationChatAdapter: (endpointUrl: string, userId: CommunicationIdentifierKind, displayName: string, credential: CommunicationTokenCredential, threadId: string) => Promise<ChatAdapter>;
Expand Down
11 changes: 10 additions & 1 deletion packages/react-composites/review/react-composites.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ export class AzureCommunicationCallAdapter implements CallAdapter {
unmute(): Promise<void>;
}

// @public (undocumented)
export type AzureCommunicationCallAdapterArgs = {
userId: CommunicationUserKind;
displayName: string;
credential: CommunicationTokenCredential;
locator: TeamsMeetingLinkLocator | GroupCallLocator;
callClientOptions?: CallClientOptions;
};

// @public (undocumented)
export interface CallAdapter {
// (undocumented)
Expand Down Expand Up @@ -375,7 +384,7 @@ export type ChatUIState = {
};

// @public (undocumented)
export const createAzureCommunicationCallAdapter: (userId: CommunicationUserKind, displayName: string, credential: CommunicationTokenCredential, locator: TeamsMeetingLinkLocator | GroupCallLocator, callClientOptions?: CallClientOptions | undefined) => Promise<CallAdapter>;
export const createAzureCommunicationCallAdapter: ({ userId, displayName, credential, locator, callClientOptions }: AzureCommunicationCallAdapterArgs) => Promise<CallAdapter>;

// @public (undocumented)
export const createAzureCommunicationChatAdapter: (endpointUrl: string, userId: CommunicationIdentifierKind, displayName: string, credential: CommunicationTokenCredential, threadId: string) => Promise<ChatAdapter>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,21 @@ const isPreviewOn = (deviceManager: DeviceManagerState): boolean => {
return deviceManager.unparentedViews.length > 0 && deviceManager.unparentedViews[0].view !== undefined;
};

export const createAzureCommunicationCallAdapter = async (
userId: CommunicationUserKind,
displayName: string,
credential: CommunicationTokenCredential,
locator: TeamsMeetingLinkLocator | GroupCallLocator,
callClientOptions?: CallClientOptions
): Promise<CallAdapter> => {
export type AzureCommunicationCallAdapterArgs = {
userId: CommunicationUserKind;
displayName: string;
credential: CommunicationTokenCredential;
locator: TeamsMeetingLinkLocator | GroupCallLocator;
callClientOptions?: CallClientOptions;
};

export const createAzureCommunicationCallAdapter = async ({
userId,
displayName,
credential,
locator,
callClientOptions
}: AzureCommunicationCallAdapterArgs): Promise<CallAdapter> => {
const callClient = createStatefulCallClient({ userId }, { callClientOptions });
const deviceManager = (await callClient.getDeviceManager()) as StatefulDeviceManager;
const callAgent = await callClient.createCallAgent(credential, { displayName });
Expand Down
10 changes: 5 additions & 5 deletions packages/react-composites/tests/browser/call/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ function App(): JSX.Element {
useEffect(() => {
const initialize = async (): Promise<void> => {
setCallAdapter(
await createAzureCommunicationCallAdapter(
{ kind: 'communicationUser', communicationUserId: userId },
await createAzureCommunicationCallAdapter({
userId: { kind: 'communicationUser', communicationUserId: userId },
displayName,
new AzureCommunicationTokenCredential(token),
{ groupId: groupId }
)
credential: new AzureCommunicationTokenCredential(token),
locator: { groupId: groupId }
})
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ export const ContosoCallContainer = (props: ContainerProps): JSX.Element => {
: { groupId: props.locator };
const createAdapter = async (credential: AzureCommunicationTokenCredential): Promise<void> => {
setAdapter(
await createAzureCommunicationCallAdapter(
{ kind: 'communicationUser', communicationUserId: props.userId.communicationUserId },
props.displayName,
await createAzureCommunicationCallAdapter({
userId: { kind: 'communicationUser', communicationUserId: props.userId.communicationUserId },
displayName: props.displayName,
credential,
callLocator
)
locator: callLocator
})
);
};
createAdapter(credential);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ export const CustomDataModelExampleContainer = (props: ContainerProps): JSX.Elem
: { groupId: props.locator };
const createAdapter = async (): Promise<void> => {
setAdapter(
await createAzureCommunicationCallAdapter(
{ kind: 'communicationUser', communicationUserId: props.userId.communicationUserId },
props.displayName,
new AzureCommunicationTokenCredential(props.token),
callLocator
)
await createAzureCommunicationCallAdapter({
userId: { kind: 'communicationUser', communicationUserId: props.userId.communicationUserId },
displayName: props.displayName,
credential: new AzureCommunicationTokenCredential(props.token),
locator: callLocator
})
);
};
createAdapter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export const MeetingExperience = (props: MeetingExampleProps): JSX.Element => {
) {
const createAdapters = async (): Promise<void> => {
setCallAdapter(
await createAzureCommunicationCallAdapter(
{ kind: 'communicationUser', communicationUserId: props.userId.communicationUserId },
props.displayName,
await createAzureCommunicationCallAdapter({
userId: { kind: 'communicationUser', communicationUserId: props.userId.communicationUserId },
displayName: props.displayName,
credential,
props.locator
)
locator: props.locator
})
);

setChatAdapter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ function App(): JSX.Element {
)
);
setCallAdapter(
await createAzureCommunicationCallAdapter(
{ kind: 'communicationUser', communicationUserId: userId },
await createAzureCommunicationCallAdapter({
userId: { kind: 'communicationUser', communicationUserId: userId },
displayName,
credential,
{ groupId }
)
locator: { groupId }
})
);
};
createAdapter(credential);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ function App(): JSX.Element {
)
);
setCallAdapter(
await createAzureCommunicationCallAdapter(
{ kind: 'communicationUser', communicationUserId: userId },
await createAzureCommunicationCallAdapter({
userId: { kind: 'communicationUser', communicationUserId: userId },
displayName,
new AzureCommunicationTokenCredential(token),
{ groupId }
)
credential: new AzureCommunicationTokenCredential(token),
locator: { groupId }
})
);
};
createAdapter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export const CallAdapterExample = (props: CallAdapterExampleProps): JSX.Element
if (props) {
const createAdapter = async (): Promise<void> => {
setCallAdapter(
await createAzureCommunicationCallAdapter(
{ kind: 'communicationUser', communicationUserId: props.userId.communicationUserId },
props.displayName,
new AzureCommunicationTokenCredential(props.accessToken),
props.callLocator
)
await createAzureCommunicationCallAdapter({
userId: { kind: 'communicationUser', communicationUserId: props.userId.communicationUserId },
displayName: props.displayName,
credential: new AzureCommunicationTokenCredential(props.accessToken),
locator: props.callLocator
})
);
};
createAdapter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ function App(): JSX.Element {
)
);
setCallAdapter(
await createAzureCommunicationCallAdapter(
{ kind: 'communicationUser', communicationUserId: userId },
await createAzureCommunicationCallAdapter({
userId: { kind: 'communicationUser', communicationUserId: userId },
displayName,
new AzureCommunicationTokenCredential(token),
{ groupId }
)
credential: new AzureCommunicationTokenCredential(token),
locator: { groupId }
})
);
};
createAdapter();
Expand Down
12 changes: 6 additions & 6 deletions samples/Calling/src/app/views/CallScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ export const CallScreen = (props: CallScreenProps): JSX.Element => {

useEffect(() => {
(async () => {
const adapter = await createAzureCommunicationCallAdapter(
{ kind: 'communicationUser', communicationUserId: userId.communicationUserId },
displayName,
createAutoRefreshingCredential(userId.communicationUserId, token),
callLocator
);
const adapter = await createAzureCommunicationCallAdapter({
userId: { kind: 'communicationUser', communicationUserId: userId.communicationUserId },
displayName: displayName,
credential: createAutoRefreshingCredential(userId.communicationUserId, token),
locator: callLocator
});
adapter.on('callEnded', () => {
onCallEnded();
});
Expand Down
10 changes: 5 additions & 5 deletions samples/StaticHtmlComposites/src/callComposite.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { CallComposite, createAzureCommunicationCallAdapter } from '@azure/commu

export const loadCallComposite = async function (args, htmlElement) {
const { userId, token, groupId, displayName } = args;
const adapter = await createAzureCommunicationCallAdapter(
const adapter = await createAzureCommunicationCallAdapter({
userId,
displayName ?? 'anonymous',
new AzureCommunicationTokenCredential(token),
{ groupId }
);
displayName: displayName ?? 'anonymous',
credential: new AzureCommunicationTokenCredential(token),
locator: { groupId }
});
ReactDOM.render(React.createElement(CallComposite, { adapter }, null), htmlElement);
return adapter;
};

0 comments on commit f16a14c

Please sign in to comment.