Skip to content

Commit 60bb0b2

Browse files
Support Teams' short meeting URLs (#4481)
1 parent 4c93ccb commit 60bb0b2

3 files changed

Lines changed: 52 additions & 2 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": "improvement",
4+
"workstream": "",
5+
"comment": "Lay groundwork for supporting the new Teams' short meeting URLs",
6+
"packageName": "@azure/communication-react",
7+
"email": "2684369+JamesBurnside@users.noreply.github.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": "improvement",
4+
"workstream": "",
5+
"comment": "Lay groundwork for supporting the new Teams' short meeting URLs",
6+
"packageName": "@azure/communication-react",
7+
"email": "2684369+JamesBurnside@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}

packages/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,12 +899,44 @@ export class CallAndChatProvider implements ChatThreadProvider {
899899
*/
900900
export class TeamsMeetingLinkProvider implements ChatThreadProvider {
901901
public locator: TeamsMeetingLinkLocator;
902+
/** @conditional-compile-remove(meeting-id) */
903+
private callAdapterPromise: Promise<CallAdapter>;
904+
/** @conditional-compile-remove(meeting-id) */
905+
private callAdapterSubscription?: (state: CallAdapterState) => void;
902906

903-
constructor(locator: TeamsMeetingLinkLocator) {
907+
constructor(
908+
locator: TeamsMeetingLinkLocator,
909+
/** @conditional-compile-remove(meeting-id) */ callAdapterPromise: Promise<CallAdapter>
910+
) {
904911
this.locator = locator;
912+
/** @conditional-compile-remove(meeting-id) */
913+
this.callAdapterPromise = callAdapterPromise;
905914
}
906915

907916
public async getChatThread(): Promise<string> {
917+
/** @conditional-compile-remove(meeting-id) */
918+
{
919+
// Wait for the call to be connected and get the chat thread ID from `call.callInfo`.
920+
const chatThreadPromise = new Promise<string>((resolve) => {
921+
this.callAdapterPromise.then((callAdapter) => {
922+
// Ensure function is idempotent by removing any existing subscription.
923+
this.callAdapterSubscription && callAdapter.offStateChange(this.callAdapterSubscription);
924+
925+
this.callAdapterSubscription = (state: CallAdapterState): void => {
926+
if (state.call?.state === 'Connected' && state.call.info?.threadId) {
927+
this.callAdapterSubscription && callAdapter.offStateChange(this.callAdapterSubscription);
928+
this.callAdapterSubscription = undefined;
929+
930+
resolve(state.call.info?.threadId);
931+
}
932+
};
933+
callAdapter.onStateChange(this.callAdapterSubscription);
934+
});
935+
});
936+
937+
return chatThreadPromise;
938+
}
939+
908940
return getChatThreadFromTeamsLink(this.locator.meetingLink);
909941
}
910942
}
@@ -1231,7 +1263,7 @@ const _createChatThreadAdapterInner = (
12311263
adapter: Promise<CallAdapter>
12321264
): ChatThreadProvider => {
12331265
if ('meetingLink' in locator) {
1234-
return new TeamsMeetingLinkProvider(locator);
1266+
return new TeamsMeetingLinkProvider(locator, /** @conditional-compile-remove(meeting-id) */ adapter);
12351267
}
12361268
/** @conditional-compile-remove(meeting-id) */
12371269
if ('meetingId' in locator) {

0 commit comments

Comments
 (0)