@azure/communication-react 1.16.0-alpha-202404252104 → 1.16.0-alpha-202404270012

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/communication-react.d.ts +12 -1
  2. package/dist/dist-cjs/communication-react/{ChatMessageComponentAsRichTextEditBox-CWvESa8u.js → ChatMessageComponentAsRichTextEditBox-DSlV4PZz.js} +2 -2
  3. package/dist/dist-cjs/communication-react/{ChatMessageComponentAsRichTextEditBox-CWvESa8u.js.map → ChatMessageComponentAsRichTextEditBox-DSlV4PZz.js.map} +1 -1
  4. package/dist/dist-cjs/communication-react/{index-BTXDJhYg.js → index-aGXLnB_I.js} +271 -100
  5. package/dist/dist-cjs/communication-react/index-aGXLnB_I.js.map +1 -0
  6. package/dist/dist-cjs/communication-react/index.js +1 -1
  7. package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js +1 -1
  8. package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js.map +1 -1
  9. package/dist/dist-esm/calling-component-bindings/src/captionsSelector.js +1 -1
  10. package/dist/dist-esm/calling-component-bindings/src/captionsSelector.js.map +1 -1
  11. package/dist/dist-esm/calling-stateful-client/src/Converter.js +1 -1
  12. package/dist/dist-esm/calling-stateful-client/src/Converter.js.map +1 -1
  13. package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageContent.js +28 -1
  14. package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageContent.js.map +1 -1
  15. package/dist/dist-esm/react-components/src/components/DevicesButton.d.ts +2 -1
  16. package/dist/dist-esm/react-components/src/components/DevicesButton.js +6 -2
  17. package/dist/dist-esm/react-components/src/components/DevicesButton.js.map +1 -1
  18. package/dist/dist-esm/react-components/src/components/InputBoxButton.d.ts +1 -0
  19. package/dist/dist-esm/react-components/src/components/InputBoxButton.js +9 -8
  20. package/dist/dist-esm/react-components/src/components/InputBoxButton.js.map +1 -1
  21. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/RichTextInsertTableButton.js +1 -1
  22. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/RichTextInsertTableButton.js.map +1 -1
  23. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/RichTextInsertTablePane.d.ts +1 -2
  24. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/RichTextInsertTablePane.js +4 -2
  25. package/dist/dist-esm/react-components/src/components/RichTextEditor/Buttons/Table/RichTextInsertTablePane.js.map +1 -1
  26. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js +22 -7
  27. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js.map +1 -1
  28. package/dist/dist-esm/react-components/src/components/SendBox.js +16 -6
  29. package/dist/dist-esm/react-components/src/components/SendBox.js.map +1 -1
  30. package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.d.ts +15 -0
  31. package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.js +19 -0
  32. package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.js.map +1 -1
  33. package/dist/dist-esm/react-composites/src/composites/CallComposite/CallComposite.js +3 -2
  34. package/dist/dist-esm/react-composites/src/composites/CallComposite/CallComposite.js.map +1 -1
  35. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/CallWithChatComposite.js +3 -1
  36. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/CallWithChatComposite.js.map +1 -1
  37. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/ChatButton/useUnreadMessagesTracker.d.ts +1 -1
  38. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/ChatButton/useUnreadMessagesTracker.js +3 -3
  39. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/ChatButton/useUnreadMessagesTracker.js.map +1 -1
  40. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.d.ts +26 -12
  41. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js +130 -66
  42. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js.map +1 -1
  43. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.d.ts +11 -1
  44. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.js.map +1 -1
  45. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/index.d.ts +1 -1
  46. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/index.js.map +1 -1
  47. package/dist/dist-esm/react-composites/src/composites/common/AudioProvider.d.ts +19 -0
  48. package/dist/dist-esm/react-composites/src/composites/common/AudioProvider.js +25 -0
  49. package/dist/dist-esm/react-composites/src/composites/common/AudioProvider.js.map +1 -0
  50. package/dist/dist-esm/react-composites/src/composites/common/BaseComposite.js +7 -1
  51. package/dist/dist-esm/react-composites/src/composites/common/BaseComposite.js.map +1 -1
  52. package/package.json +1 -1
  53. package/dist/dist-cjs/communication-react/index-BTXDJhYg.js.map +0 -1
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  });
11
11
  };
12
12
  import { callWithChatAdapterStateFromBackingStates, mergeCallAdapterStateIntoCallWithChatAdapterState, mergeChatAdapterStateIntoCallWithChatAdapterState } from '../state/CallWithChatAdapterState';
13
- import { _createLazyAzureCommunicationChatAdapterInner, createAzureCommunicationChatAdapterFromClient } from '../../ChatComposite/adapter/AzureCommunicationChatAdapter';
13
+ import { _createAzureCommunicationChatAdapterInner, _createLazyAzureCommunicationChatAdapterInner, createAzureCommunicationChatAdapterFromClient } from '../../ChatComposite/adapter/AzureCommunicationChatAdapter';
14
14
  import { EventEmitter } from 'events';
15
15
  /* @conditional-compile-remove(PSTN-calls) */
16
16
  import { isCommunicationUserIdentifier } from '@azure/communication-common';
@@ -54,44 +54,48 @@ class CallWithChatContext {
54
54
  * Created for easy use with the {@link CallWithChatComposite}.
55
55
  */
56
56
  export class AzureCommunicationCallWithChatAdapter {
57
- constructor(callAdapter, chatAdapterPromise) {
57
+ constructor(callAdapter, chatAdapter) {
58
+ this.emitter = new EventEmitter();
59
+ this.isAdapterDisposed = false;
58
60
  /* @conditional-compile-remove(attachment-upload) */
59
61
  this.registerActiveUploads = (files) => {
60
- var _a, _b;
61
- return (_b = (_a = this.chatAdapter) === null || _a === void 0 ? void 0 : _a.registerActiveUploads(files)) !== null && _b !== void 0 ? _b : [];
62
+ return this.executeWithResolvedChatAdapter((adapter) => {
63
+ return adapter.registerActiveUploads(files);
64
+ });
62
65
  };
63
66
  /* @conditional-compile-remove(attachment-upload) */
64
67
  this.registerCompletedUploads = (metadata) => {
65
- var _a, _b;
66
- return (_b = (_a = this.chatAdapter) === null || _a === void 0 ? void 0 : _a.registerCompletedUploads(metadata)) !== null && _b !== void 0 ? _b : [];
68
+ return this.executeWithResolvedChatAdapter((adapter) => {
69
+ return adapter.registerCompletedUploads(metadata);
70
+ });
67
71
  };
68
72
  /* @conditional-compile-remove(attachment-upload) */
69
73
  this.clearUploads = () => {
70
- this.chatAdapterPromise.then((adapter) => {
74
+ this.executeWithResolvedChatAdapter((adapter) => {
71
75
  adapter.clearUploads();
72
76
  });
73
77
  };
74
78
  /* @conditional-compile-remove(attachment-upload) */
75
79
  this.cancelUpload = (id) => {
76
- this.chatAdapterPromise.then((adapter) => {
80
+ this.executeWithResolvedChatAdapter((adapter) => {
77
81
  adapter.cancelUpload(id);
78
82
  });
79
83
  };
80
84
  /* @conditional-compile-remove(attachment-upload) */
81
85
  this.updateUploadProgress = (id, progress) => {
82
- this.chatAdapterPromise.then((adapter) => {
86
+ this.executeWithResolvedChatAdapter((adapter) => {
83
87
  adapter.updateUploadProgress(id, progress);
84
88
  });
85
89
  };
86
90
  /* @conditional-compile-remove(attachment-upload) */
87
91
  this.updateUploadStatusMessage = (id, errorMessage) => {
88
- this.chatAdapterPromise.then((adapter) => {
92
+ this.executeWithResolvedChatAdapter((adapter) => {
89
93
  adapter.updateUploadStatusMessage(id, errorMessage);
90
94
  });
91
95
  };
92
96
  /* @conditional-compile-remove(attachment-upload) */
93
97
  this.updateUploadMetadata = (id, metadata) => {
94
- this.chatAdapterPromise.then((adapter) => {
98
+ this.executeWithResolvedChatAdapter((adapter) => {
95
99
  adapter.updateUploadMetadata(id, metadata);
96
100
  });
97
101
  };
@@ -102,19 +106,28 @@ export class AzureCommunicationCallWithChatAdapter {
102
106
  this.context.updateClientStateWithChatState(newChatAdapterState);
103
107
  };
104
108
  this.onChatStateChange = onChatStateChange;
105
- this.chatAdapterPromise = chatAdapterPromise;
106
- this.chatAdapterPromise.then((chatAdapter) => {
107
- chatAdapter.onStateChange(this.onChatStateChange);
108
- /* @conditional-compile-remove(attachment-download) @conditional-compile-remove(attachment-upload) */
109
- this.chatAdapter = chatAdapter;
110
- this.context.updateClientStateWithChatState(chatAdapter.getState());
111
- });
109
+ if (chatAdapter) {
110
+ this.updateChatAdapter(chatAdapter);
111
+ }
112
112
  const onCallStateChange = (newCallAdapterState) => {
113
113
  this.context.updateClientStateWithCallState(newCallAdapterState);
114
114
  };
115
115
  this.callAdapter.onStateChange(onCallStateChange);
116
116
  this.onCallStateChange = onCallStateChange;
117
117
  }
118
+ setChatAdapterPromise(chatAdapter) {
119
+ chatAdapter.then((adapter) => {
120
+ if (!this.isAdapterDisposed) {
121
+ this.updateChatAdapter(adapter);
122
+ }
123
+ });
124
+ }
125
+ updateChatAdapter(chatAdapter) {
126
+ this.chatAdapter = chatAdapter;
127
+ this.chatAdapter.onStateChange(this.onChatStateChange);
128
+ this.context.updateClientStateWithChatState(chatAdapter.getState());
129
+ this.emitter.emit('chatInitialized', this.chatAdapter);
130
+ }
118
131
  bindPublicMethods() {
119
132
  this.joinCall.bind(this);
120
133
  this.leaveCall.bind(this);
@@ -235,16 +248,13 @@ export class AzureCommunicationCallWithChatAdapter {
235
248
  }
236
249
  /** Dispose of the current CallWithChatAdapter. */
237
250
  dispose() {
238
- return __awaiter(this, void 0, void 0, function* () {
239
- this.chatAdapterPromise.then((adapter) => {
240
- adapter.offStateChange(this.onChatStateChange);
241
- });
242
- this.callAdapter.offStateChange(this.onCallStateChange);
243
- yield this.chatAdapterPromise.then((adapter) => {
244
- adapter.dispose();
245
- });
246
- this.callAdapter.dispose();
247
- });
251
+ this.isAdapterDisposed = true;
252
+ if (this.chatAdapter) {
253
+ this.chatAdapter.offStateChange(this.onChatStateChange);
254
+ this.chatAdapter.dispose();
255
+ }
256
+ this.callAdapter.offStateChange(this.onCallStateChange);
257
+ this.callAdapter.dispose();
248
258
  }
249
259
  /** Remove a participant from the Call only. */
250
260
  removeParticipant(userId) {
@@ -382,7 +392,7 @@ export class AzureCommunicationCallWithChatAdapter {
382
392
  /** Fetch initial Call and Chat data such as chat messages. */
383
393
  fetchInitialData() {
384
394
  return __awaiter(this, void 0, void 0, function* () {
385
- return yield this.chatAdapterPromise.then((adapter) => {
395
+ return yield this.executeWithResolvedChatAdapter((adapter) => {
386
396
  return adapter.fetchInitialData();
387
397
  });
388
398
  });
@@ -390,7 +400,7 @@ export class AzureCommunicationCallWithChatAdapter {
390
400
  /** Send a chat message. */
391
401
  sendMessage(content) {
392
402
  return __awaiter(this, void 0, void 0, function* () {
393
- return yield this.chatAdapterPromise.then((adapter) => {
403
+ return yield this.executeWithResolvedChatAdapter((adapter) => {
394
404
  return adapter.sendMessage(content);
395
405
  });
396
406
  });
@@ -399,7 +409,7 @@ export class AzureCommunicationCallWithChatAdapter {
399
409
  /** Send a chat message with attachments. */
400
410
  sendMessageWithAttachments(content, attachments) {
401
411
  return __awaiter(this, void 0, void 0, function* () {
402
- return yield this.chatAdapterPromise.then((adapter) => {
412
+ return yield this.executeWithResolvedChatAdapter((adapter) => {
403
413
  const fileSharingMetadata = {
404
414
  fileSharingMetadata: JSON.stringify(attachments)
405
415
  };
@@ -412,7 +422,7 @@ export class AzureCommunicationCallWithChatAdapter {
412
422
  /** Send a chat read receipt. */
413
423
  sendReadReceipt(chatMessageId) {
414
424
  return __awaiter(this, void 0, void 0, function* () {
415
- return yield this.chatAdapterPromise.then((adapter) => {
425
+ return yield this.executeWithResolvedChatAdapter((adapter) => {
416
426
  return adapter.sendReadReceipt(chatMessageId);
417
427
  });
418
428
  });
@@ -420,7 +430,7 @@ export class AzureCommunicationCallWithChatAdapter {
420
430
  /** Send an isTyping indicator. */
421
431
  sendTypingIndicator() {
422
432
  return __awaiter(this, void 0, void 0, function* () {
423
- return yield this.chatAdapterPromise.then((adapter) => {
433
+ return yield this.executeWithResolvedChatAdapter((adapter) => {
424
434
  return adapter.sendTypingIndicator();
425
435
  });
426
436
  });
@@ -428,7 +438,7 @@ export class AzureCommunicationCallWithChatAdapter {
428
438
  /** Load previous Chat messages. */
429
439
  loadPreviousChatMessages(messagesToLoad) {
430
440
  return __awaiter(this, void 0, void 0, function* () {
431
- return yield this.chatAdapterPromise.then((adapter) => {
441
+ return yield this.executeWithResolvedChatAdapter((adapter) => {
432
442
  return adapter.loadPreviousChatMessages(messagesToLoad);
433
443
  });
434
444
  });
@@ -436,7 +446,7 @@ export class AzureCommunicationCallWithChatAdapter {
436
446
  /** Update an existing message. */
437
447
  updateMessage(messageId, content, metadata, options) {
438
448
  return __awaiter(this, void 0, void 0, function* () {
439
- return this.chatAdapterPromise.then((adapter) => {
449
+ return this.executeWithResolvedChatAdapter((adapter) => {
440
450
  return adapter.updateMessage(messageId, content, metadata,
441
451
  /* @conditional-compile-remove(attachment-upload) */ options);
442
452
  });
@@ -445,20 +455,20 @@ export class AzureCommunicationCallWithChatAdapter {
445
455
  /** Delete an existing message. */
446
456
  deleteMessage(messageId) {
447
457
  return __awaiter(this, void 0, void 0, function* () {
448
- return yield this.chatAdapterPromise.then((adapter) => {
458
+ return yield this.executeWithResolvedChatAdapter((adapter) => {
449
459
  return adapter.deleteMessage(messageId);
450
460
  });
451
461
  });
452
462
  }
453
463
  downloadResourceToCache(resourceDetails) {
454
464
  return __awaiter(this, void 0, void 0, function* () {
455
- this.chatAdapterPromise.then((adapter) => {
465
+ this.executeWithResolvedChatAdapter((adapter) => {
456
466
  adapter.downloadResourceToCache(resourceDetails);
457
467
  });
458
468
  });
459
469
  }
460
470
  removeResourceFromCache(resourceDetails) {
461
- this.chatAdapterPromise.then((adapter) => {
471
+ this.executeWithResolvedChatAdapter((adapter) => {
462
472
  adapter.removeResourceFromCache(resourceDetails);
463
473
  });
464
474
  }
@@ -600,37 +610,37 @@ export class AzureCommunicationCallWithChatAdapter {
600
610
  this.callAdapter.on('isSpokenLanguageChanged', listener);
601
611
  break;
602
612
  case 'messageReceived':
603
- this.chatAdapterPromise.then((adapter) => {
613
+ this.executeWithResolvedChatAdapter((adapter) => {
604
614
  adapter.on('messageReceived', listener);
605
615
  });
606
616
  break;
607
617
  case 'messageEdited':
608
- this.chatAdapterPromise.then((adapter) => {
618
+ this.executeWithResolvedChatAdapter((adapter) => {
609
619
  adapter.on('messageEdited', listener);
610
620
  });
611
621
  break;
612
622
  case 'messageDeleted':
613
- this.chatAdapterPromise.then((adapter) => {
623
+ this.executeWithResolvedChatAdapter((adapter) => {
614
624
  adapter.on('messageDeleted', listener);
615
625
  });
616
626
  break;
617
627
  case 'messageSent':
618
- this.chatAdapterPromise.then((adapter) => {
628
+ this.executeWithResolvedChatAdapter((adapter) => {
619
629
  adapter.on('messageSent', listener);
620
630
  });
621
631
  break;
622
632
  case 'messageRead':
623
- this.chatAdapterPromise.then((adapter) => {
633
+ this.executeWithResolvedChatAdapter((adapter) => {
624
634
  adapter.on('messageRead', listener);
625
635
  });
626
636
  break;
627
637
  case 'chatParticipantsAdded':
628
- this.chatAdapterPromise.then((adapter) => {
638
+ this.executeWithResolvedChatAdapter((adapter) => {
629
639
  adapter.on('participantsAdded', listener);
630
640
  });
631
641
  break;
632
642
  case 'chatParticipantsRemoved':
633
- this.chatAdapterPromise.then((adapter) => {
643
+ this.executeWithResolvedChatAdapter((adapter) => {
634
644
  adapter.on('participantsRemoved', listener);
635
645
  });
636
646
  break;
@@ -638,10 +648,13 @@ export class AzureCommunicationCallWithChatAdapter {
638
648
  this.callAdapter.on('error', listener);
639
649
  break;
640
650
  case 'chatError':
641
- this.chatAdapterPromise.then((adapter) => {
651
+ this.executeWithResolvedChatAdapter((adapter) => {
642
652
  adapter.on('error', listener);
643
653
  });
644
654
  break;
655
+ case 'chatInitialized':
656
+ this.emitter.on(event, listener);
657
+ break;
645
658
  default:
646
659
  throw `Unknown AzureCommunicationCallWithChatAdapter Event: ${event}`;
647
660
  }
@@ -692,37 +705,37 @@ export class AzureCommunicationCallWithChatAdapter {
692
705
  this.callAdapter.off('isSpokenLanguageChanged', listener);
693
706
  break;
694
707
  case 'messageReceived':
695
- this.chatAdapterPromise.then((adapter) => {
708
+ this.executeWithResolvedChatAdapter((adapter) => {
696
709
  adapter.off('messageReceived', listener);
697
710
  });
698
711
  break;
699
712
  case 'messageEdited':
700
- this.chatAdapterPromise.then((adapter) => {
713
+ this.executeWithResolvedChatAdapter((adapter) => {
701
714
  adapter.off('messageEdited', listener);
702
715
  });
703
716
  break;
704
717
  case 'messageDeleted':
705
- this.chatAdapterPromise.then((adapter) => {
718
+ this.executeWithResolvedChatAdapter((adapter) => {
706
719
  adapter.off('messageDeleted', listener);
707
720
  });
708
721
  break;
709
722
  case 'messageSent':
710
- this.chatAdapterPromise.then((adapter) => {
723
+ this.executeWithResolvedChatAdapter((adapter) => {
711
724
  adapter.off('messageSent', listener);
712
725
  });
713
726
  break;
714
727
  case 'messageRead':
715
- this.chatAdapterPromise.then((adapter) => {
728
+ this.executeWithResolvedChatAdapter((adapter) => {
716
729
  adapter.off('messageRead', listener);
717
730
  });
718
731
  break;
719
732
  case 'chatParticipantsAdded':
720
- this.chatAdapterPromise.then((adapter) => {
733
+ this.executeWithResolvedChatAdapter((adapter) => {
721
734
  adapter.off('participantsAdded', listener);
722
735
  });
723
736
  break;
724
737
  case 'chatParticipantsRemoved':
725
- this.chatAdapterPromise.then((adapter) => {
738
+ this.executeWithResolvedChatAdapter((adapter) => {
726
739
  adapter.off('participantsRemoved', listener);
727
740
  });
728
741
  break;
@@ -730,33 +743,51 @@ export class AzureCommunicationCallWithChatAdapter {
730
743
  this.callAdapter.off('error', listener);
731
744
  break;
732
745
  case 'chatError':
733
- this.chatAdapterPromise.then((adapter) => {
746
+ this.executeWithResolvedChatAdapter((adapter) => {
734
747
  adapter.off('error', listener);
735
748
  });
736
749
  break;
750
+ case 'chatInitialized':
751
+ this.emitter.off(event, listener);
752
+ break;
737
753
  default:
738
754
  throw `Unknown AzureCommunicationCallWithChatAdapter Event: ${event}`;
739
755
  }
740
756
  }
757
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
758
+ executeWithResolvedChatAdapter(callback) {
759
+ if (!this.chatAdapter) {
760
+ console.error('Chat is not initialized');
761
+ }
762
+ else {
763
+ return callback(this.chatAdapter);
764
+ }
765
+ }
741
766
  }
742
767
  /**
743
768
  * Arguments for use in {@link createAzureCommunicationCallWithChatAdapter} to join a Group Call with an associated Chat thread.
744
- * @public
769
+ * @private
745
770
  */
746
771
  export class CallAndChatProvider {
747
772
  constructor(locator) {
748
773
  this.locator = locator;
749
774
  }
750
- getChatThread() {
775
+ isCallInfoRequired() {
776
+ return false;
777
+ }
778
+ getChatThreadPromise() {
751
779
  return __awaiter(this, void 0, void 0, function* () {
752
- return this.locator.chatThreadId;
780
+ return this.getChatThread();
753
781
  });
754
782
  }
783
+ getChatThread() {
784
+ return this.locator.chatThreadId;
785
+ }
755
786
  }
756
787
  /**
757
788
  * Arguments for use in {@link createAzureCommunicationCallWithChatAdapter} to join a Teams meeting with an associated Chat thread.
758
789
  *
759
- * @public
790
+ * @private
760
791
  */
761
792
  export class TeamsMeetingLinkProvider {
762
793
  constructor(locator,
@@ -765,7 +796,15 @@ export class TeamsMeetingLinkProvider {
765
796
  /** @conditional-compile-remove(meeting-id) */
766
797
  this.callAdapterPromise = callAdapterPromise;
767
798
  }
799
+ isCallInfoRequired() {
800
+ return true;
801
+ }
768
802
  getChatThread() {
803
+ /** @conditional-compile-remove(meeting-id) */
804
+ throw new Error('Chat thread ID should be retrieved from call.callInfo using method getChatThreadPromise');
805
+ return getChatThreadFromTeamsLink(this.locator.meetingLink);
806
+ }
807
+ getChatThreadPromise() {
769
808
  return __awaiter(this, void 0, void 0, function* () {
770
809
  /** @conditional-compile-remove(meeting-id) */
771
810
  {
@@ -795,28 +834,45 @@ export class TeamsMeetingLinkProvider {
795
834
  /**
796
835
  * Arguments for use in {@link createAzureCommunicationCallWithChatAdapter} to join a Teams meeting using meeting id.
797
836
  *
798
- * @public
837
+ * @private
799
838
  */
800
839
  export class TeamsMeetingIdProvider {
801
840
  constructor(locator, callAdapter) {
802
841
  this.locator = locator;
803
842
  this.callAdapter = callAdapter;
804
843
  }
844
+ isCallInfoRequired() {
845
+ return true;
846
+ }
847
+ getChatThread() {
848
+ throw new Error('Chat thread ID is not available for Teams meeting ID');
849
+ }
805
850
  /**
806
851
  * Wait call to be connected to get thread ID.
807
852
  * @returns the chat thread ID for the given meeting ID.
808
853
  */
809
- getChatThread() {
854
+ getChatThreadPromise() {
810
855
  return __awaiter(this, void 0, void 0, function* () {
811
856
  return new Promise((resolve) => {
812
857
  const stateChangeListener = (state) => {
813
858
  var _a, _b, _c;
814
859
  if (((_a = state.call) === null || _a === void 0 ? void 0 : _a.state) === 'Connected' && ((_b = state.call.info) === null || _b === void 0 ? void 0 : _b.threadId)) {
860
+ this.callAdapter.then((adapter) => {
861
+ adapter.offStateChange(stateChangeListener);
862
+ });
815
863
  resolve((_c = state.call.info) === null || _c === void 0 ? void 0 : _c.threadId);
816
864
  }
817
865
  };
818
866
  this.callAdapter.then((adapter) => {
819
- adapter.onStateChange(stateChangeListener);
867
+ var _a, _b, _c;
868
+ const callState = (_a = adapter.getState().call) === null || _a === void 0 ? void 0 : _a.state;
869
+ const threadId = (_c = (_b = adapter.getState().call) === null || _b === void 0 ? void 0 : _b.info) === null || _c === void 0 ? void 0 : _c.threadId;
870
+ if (callState === 'Connected' && threadId) {
871
+ resolve(threadId);
872
+ }
873
+ else {
874
+ adapter.onStateChange(stateChangeListener);
875
+ }
820
876
  });
821
877
  });
822
878
  });
@@ -841,8 +897,16 @@ export const createAzureCommunicationCallWithChatAdapter = (_a) => __awaiter(voi
841
897
  telemetryImplementationHint: 'CallWithChat'
842
898
  });
843
899
  const chatThreadAdapter = _createChatThreadAdapterInner(locator, callAdapter);
844
- const chatAdapter = _createLazyAzureCommunicationChatAdapterInner(endpoint, userId, displayName, credential, chatThreadAdapter.getChatThread(), 'CallWithChat');
845
- return new AzureCommunicationCallWithChatAdapter(yield callAdapter, chatAdapter);
900
+ if (chatThreadAdapter.isCallInfoRequired()) {
901
+ const callWithChatAdapter = new AzureCommunicationCallWithChatAdapter(yield callAdapter);
902
+ const chatAdapterPromise = _createLazyAzureCommunicationChatAdapterInner(endpoint, userId, displayName, credential, chatThreadAdapter.getChatThreadPromise(), 'CallWithChat');
903
+ callWithChatAdapter.setChatAdapterPromise(chatAdapterPromise);
904
+ return callWithChatAdapter;
905
+ }
906
+ else {
907
+ const chatAdapter = _createAzureCommunicationChatAdapterInner(endpoint, userId, displayName, credential, chatThreadAdapter.getChatThread(), 'CallWithChat');
908
+ return new AzureCommunicationCallWithChatAdapter(yield callAdapter, yield chatAdapter);
909
+ }
846
910
  });
847
911
  /**
848
912
  * A custom React hook to simplify the creation of {@link CallWithChatAdapter}.
@@ -971,8 +1035,8 @@ beforeDispose) => {
971
1035
  */
972
1036
  export const createAzureCommunicationCallWithChatAdapterFromClients = (_b) => __awaiter(void 0, [_b], void 0, function* ({ callClient, callAgent, callLocator, chatClient, chatThreadClient, callAdapterOptions }) {
973
1037
  const callAdapter = yield createAzureCommunicationCallAdapterFromClient(callClient, callAgent, callLocator, callAdapterOptions);
974
- const chatAdapterPromise = createAzureCommunicationChatAdapterFromClient(chatClient, chatThreadClient);
975
- return new AzureCommunicationCallWithChatAdapter(callAdapter, chatAdapterPromise);
1038
+ const chatAdapter = yield createAzureCommunicationChatAdapterFromClient(chatClient, chatThreadClient);
1039
+ return new AzureCommunicationCallWithChatAdapter(callAdapter, chatAdapter);
976
1040
  });
977
1041
  /**
978
1042
  * Create a {@link CallWithChatAdapter} from the underlying adapters.
@@ -981,7 +1045,7 @@ export const createAzureCommunicationCallWithChatAdapterFromClients = (_b) => __
981
1045
  *
982
1046
  * @internal
983
1047
  */
984
- export const _createAzureCommunicationCallWithChatAdapterFromAdapters = (callAdapter, chatAdapter) => new AzureCommunicationCallWithChatAdapter(callAdapter, new Promise((resolve) => resolve(chatAdapter)));
1048
+ export const _createAzureCommunicationCallWithChatAdapterFromAdapters = (callAdapter, chatAdapter) => new AzureCommunicationCallWithChatAdapter(callAdapter, chatAdapter);
985
1049
  const isTeamsMeetingLocator = (locator) => {
986
1050
  return 'meetingLink' in locator || 'meetingId' in locator;
987
1051
  };