@microsoft/omnichannel-chat-widget 0.1.0-main.ae3aa42 → 0.1.0-main.b511ad6

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 (123) hide show
  1. package/README.md +32 -0
  2. package/lib/cjs/common/Constants.js +16 -2
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +26 -3
  4. package/lib/cjs/common/telemetry/TelemetryManager.js +7 -1
  5. package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +8 -9
  6. package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
  7. package/lib/cjs/common/utils.js +63 -2
  8. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
  9. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +20 -4
  10. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
  11. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
  12. package/lib/cjs/components/headerstateful/HeaderStateful.js +2 -2
  13. package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
  14. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
  15. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  16. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
  17. package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
  18. package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
  19. package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
  20. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
  21. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +9 -15
  22. package/lib/cjs/components/livechatwidget/common/endChat.js +63 -16
  23. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +20 -3
  24. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +23 -15
  25. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  26. package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
  27. package/lib/cjs/components/livechatwidget/common/startChat.js +177 -67
  28. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +206 -85
  29. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -10
  30. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
  31. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -0
  32. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
  33. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  34. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
  35. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  36. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
  37. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
  38. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
  39. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
  40. package/lib/cjs/contexts/common/ConversationState.js +3 -2
  41. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +24 -21
  42. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +3 -2
  43. package/lib/cjs/contexts/createReducer.js +16 -0
  44. package/lib/cjs/controller/componentController.js +3 -3
  45. package/lib/cjs/plugins/newMessageEventHandler.js +10 -13
  46. package/lib/esm/common/Constants.js +16 -2
  47. package/lib/esm/common/telemetry/TelemetryConstants.js +26 -3
  48. package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
  49. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +8 -6
  50. package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
  51. package/lib/esm/common/utils.js +44 -0
  52. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
  53. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +22 -7
  54. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
  55. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
  56. package/lib/esm/components/headerstateful/HeaderStateful.js +2 -2
  57. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
  58. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
  59. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  60. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
  61. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
  62. package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
  63. package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
  64. package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
  65. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +9 -15
  66. package/lib/esm/components/livechatwidget/common/endChat.js +61 -17
  67. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +19 -5
  68. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +23 -15
  69. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  70. package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
  71. package/lib/esm/components/livechatwidget/common/startChat.js +172 -68
  72. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +197 -87
  73. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +7 -11
  74. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
  75. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -0
  76. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
  77. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  78. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
  79. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  80. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
  81. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
  82. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
  83. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
  84. package/lib/esm/contexts/common/ConversationState.js +3 -2
  85. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +24 -21
  86. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +3 -2
  87. package/lib/esm/contexts/createReducer.js +16 -0
  88. package/lib/esm/controller/componentController.js +3 -3
  89. package/lib/esm/plugins/newMessageEventHandler.js +10 -12
  90. package/lib/types/common/Constants.d.ts +8 -1
  91. package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
  92. package/lib/types/common/telemetry/TelemetryConstants.d.ts +25 -5
  93. package/lib/types/common/telemetry/TelemetryHelper.d.ts +2 -1
  94. package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
  95. package/lib/types/common/utils.d.ts +6 -1
  96. package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +1 -1
  97. package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
  98. package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
  99. package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
  100. package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
  101. package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
  102. package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
  103. package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
  104. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
  105. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
  106. package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
  107. package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
  108. package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +1 -1
  109. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -0
  110. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
  111. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
  112. package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
  113. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
  114. package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
  115. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +1 -1
  116. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.d.ts +1 -1
  117. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
  118. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
  119. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
  120. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  121. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -1
  122. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +24 -21
  123. package/package.json +2 -2
@@ -0,0 +1,33 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ export class Deferred {
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ constructor() {
6
+ _defineProperty(this, "_promise", void 0);
7
+
8
+ _defineProperty(this, "_resolve", void 0);
9
+
10
+ _defineProperty(this, "_reject", () => {
11
+ return;
12
+ });
13
+
14
+ _defineProperty(this, "resolve", value => {
15
+ this._resolve(value);
16
+ });
17
+
18
+ _defineProperty(this, "reject", value => {
19
+ this._reject(value);
20
+ });
21
+
22
+ this._promise = new Promise((resolve, reject) => {
23
+ this._resolve = resolve;
24
+ this._reject = reject;
25
+ });
26
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
+
28
+
29
+ get promise() {
30
+ return this._promise;
31
+ }
32
+
33
+ }
@@ -1,7 +1,9 @@
1
1
  import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
2
2
  import { NotificationLevel } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationLevel";
3
3
  import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
4
- import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
5
+ import { ChatAdapterShim } from "./ChatAdapterShim";
6
+ import { PauseActivitySubscriber } from "./ActivitySubscriber/PauseActivitySubscriber"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
7
 
6
8
  export const createAdapter = async chatSDK => {
7
9
  const chatAdapterOptionalParams = {
@@ -23,5 +25,13 @@ export const createAdapter = async chatSDK => {
23
25
  }
24
26
  }
25
27
  };
26
- return await chatSDK.createChatAdapter(chatAdapterOptionalParams);
28
+ let adapter = await chatSDK.createChatAdapter(chatAdapterOptionalParams); //so far, there is no need to convert to the shim adapter when using visual tests
29
+
30
+ if (chatSDK.isMockModeOn !== true) {
31
+ adapter = new ChatAdapterShim(adapter);
32
+ adapter.addSubscriber(new PauseActivitySubscriber());
33
+ return adapter.chatAdapter;
34
+ }
35
+
36
+ return adapter;
27
37
  };
@@ -13,26 +13,40 @@ export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineM
13
13
  breaks: !disableNewLineMarkdownSupport
14
14
  }); // ToDo: Commenting below usage of plugin until deferred bug is resolved: https://github.com/mayashavin/markdown-it-slack/issues/1
15
15
  // markdown.use(MarkdownSlack);
16
- // Markdown override for open link in new tab
17
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, quotes
16
+ } else {
17
+ markdown = new MarkdownIt(Constants.Zero, {
18
+ html: true,
19
+ linkify: true,
20
+ breaks: !disableNewLineMarkdownSupport
21
+ });
22
+ markdown.enable(["entity", // Rule to process html entity - {, ¯, "
23
+ "linkify", // Rule to replace link-like texts with link nodes
24
+ "html_block", // Rule to process html blocks and paragraphs
25
+ "html_inline", // Rule to process html tags
26
+ "newline" // Rule to proceess '\n'
27
+ ]);
28
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
29
 
19
- markdown.use(MarkdownItForInline, "url_new_win", "link_open", function (tokens, idx, env) {
20
- const targetAttrIndex = tokens[idx].attrIndex(Constants.Target); // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
21
30
 
22
- const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
31
+ markdown.use(MarkdownItForInline, "url_new_win", "link_open", function (tokens, idx, env) {
32
+ const targetAttrIndex = tokens[idx].attrIndex(Constants.Target); // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
23
33
 
24
- if (~targetAttrIndex) {
25
- tokens[idx].attrs[targetAttrIndex][1] = Constants.Blank;
26
- } else {
27
- tokens[idx].attrPush([Constants.Target, Constants.Blank]);
28
- }
34
+ const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
35
+
36
+ if (~targetAttrIndex) {
37
+ tokens[idx].attrs[targetAttrIndex][1] = Constants.Blank;
38
+ } else {
39
+ tokens[idx].attrPush([Constants.Target, Constants.Blank]);
40
+ }
41
+
42
+ const relAttrIndex = tokens[idx].attrIndex(Constants.TargetRelationship);
29
43
 
30
- const relAttrIndex = tokens[idx].attrIndex(Constants.TargetRelationship);
44
+ if (~relAttrIndex) {
45
+ tokens[idx].attrs[relAttrIndex][1] = Constants.TargetRelationshipAttributes;
46
+ } else {
47
+ tokens[idx].attrPush([Constants.TargetRelationship, Constants.TargetRelationshipAttributes]);
31
48
 
32
- if (~relAttrIndex) {
33
- tokens[idx].attrs[relAttrIndex][1] = Constants.TargetRelationshipAttributes;
34
- } else {
35
- tokens[idx].attrPush([Constants.TargetRelationship, Constants.TargetRelationshipAttributes]);
49
+ if (!disableMarkdownMessageFormatting) {
36
50
  tokens[idx].attrPush([Constants.Title, defaultMarkdownLocalizedTexts.MARKDOWN_EXTERNAL_LINK_ALT]); // eslint-disable-next-line quotes
37
51
 
38
52
  const iconTokens = markdown.parseInline(`![${defaultMarkdownLocalizedTexts.MARKDOWN_EXTERNAL_LINK_ALT}](${TRANSPARENT_GIF})`, env)[0].children;
@@ -42,20 +56,7 @@ export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineM
42
56
  tokens.splice(idx + 2, 0, ...iconTokens);
43
57
  }
44
58
  }
45
- });
46
- } else {
47
- markdown = new MarkdownIt(Constants.Zero, {
48
- html: true,
49
- linkify: true,
50
- breaks: !disableNewLineMarkdownSupport
51
- });
52
- markdown.enable(["entity", // Rule to process html entity - {, ¯, "
53
- "linkify", // Rule to replace link-like texts with link nodes
54
- "html_block", // Rule to process html blocks and paragraphs
55
- "html_inline", // Rule to process html tags
56
- "newline" // Rule to proceess '\n'
57
- ]);
58
- }
59
-
59
+ }
60
+ });
60
61
  return markdown;
61
62
  };
@@ -253,18 +253,6 @@ export const dummyDefaultProps = {
253
253
  width: "50px",
254
254
  fontSize: "18px"
255
255
  },
256
- currentCallTimerStyleProps: {
257
- borderRadius: "2px",
258
- margin: "1px",
259
- color: "#FFFFFF",
260
- paddingTop: "18px",
261
- fontSize: 12,
262
- fontFamily: "Segoe UI, Arial, sans-serif",
263
- backgroundColor: "darkgrey",
264
- height: "45px",
265
- width: "50px",
266
- textAlign: "center"
267
- },
268
256
  videoTileStyleProps: {
269
257
  width: "100%",
270
258
  marginLeft: "auto",
@@ -328,7 +316,9 @@ export const dummyDefaultProps = {
328
316
  hideChatTextContainer: false,
329
317
  hideChatSubtitle: false,
330
318
  hideChatTitle: false,
331
- hideNotificationBubble: true
319
+ hideNotificationBubble: true,
320
+ unreadMessageString: "new messages",
321
+ largeUnreadMessageString: "99+"
332
322
  },
333
323
  styleProps: {
334
324
  generalStyleProps: {
@@ -1423,7 +1413,6 @@ export const dummyDefaultProps = {
1423
1413
  startNewChatButtonClassName: undefined
1424
1414
  }
1425
1415
  },
1426
- authClientFunction: undefined,
1427
1416
  isReconnectEnabled: undefined,
1428
1417
  reconnectId: undefined,
1429
1418
  redirectInSameWindow: undefined
@@ -1688,7 +1677,12 @@ export const dummyDefaultProps = {
1688
1677
  MIDDLEWARE_MESSAGE_RETRY: "Retry",
1689
1678
  PRECHAT_REQUIRED_FIELD_MISSING_MESSAGE: "{0} field is required",
1690
1679
  MARKDOWN_EXTERNAL_LINK_ALT: "Opens in a new window; external."
1680
+ },
1681
+ botMagicCode: {
1682
+ disabled: false,
1683
+ fwdUrl: ""
1691
1684
  }
1692
1685
  },
1693
- telemetryConfig: undefined
1686
+ telemetryConfig: undefined,
1687
+ getAuthToken: undefined
1694
1688
  };
@@ -7,21 +7,38 @@ import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontro
7
7
  import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
8
8
  import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
9
9
  import { Constants } from "../../../common/Constants";
10
+ import { addDelayInMs, getWidgetEndChatEventName } from "../../../common/utils"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
11
 
11
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
12
  const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
13
- var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4;
13
+ var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
14
14
 
15
15
  const isPostChatEnabled = (_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveyenable;
16
- const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode;
17
- const conversationDetails = await chatSDK.getConversationDetails();
16
+ const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode; // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
17
 
19
- if (isPostChatEnabled === "true" && (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.canRenderPostChat) === Constants.truePascal) {
18
+ let conversationDetails = undefined;
19
+
20
+ try {
21
+ conversationDetails = await chatSDK.getConversationDetails();
22
+ } catch (erorr) {
23
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
24
+ Event: TelemetryEvent.GetConversationDetailsException,
25
+ ExceptionDetails: {
26
+ exception: `Failed to get conversation details: ${erorr}`
27
+ }
28
+ });
29
+ }
30
+
31
+ if (isPostChatEnabled === "true" && ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.canRenderPostChat) === Constants.truePascal) {
20
32
  const skipEndChatSDK = false;
21
33
  const skipCloseChat = true;
22
- await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
34
+ await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, true);
23
35
 
24
36
  if (postChatSurveyMode === PostChatSurveyMode.Embed) {
37
+ dispatch({
38
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
39
+ payload: ConversationState.PostchatLoading
40
+ });
41
+ await addDelayInMs(Constants.PostChatLoadingDurationInMs);
25
42
  const loadPostChatEvent = {
26
43
  eventName: BroadcastEvent.LoadPostChatSurvey
27
44
  };
@@ -32,13 +49,15 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
32
49
  payload: ConversationState.InActive
33
50
  });
34
51
  }
35
- } else {
36
- await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
52
+
53
+ return;
37
54
  }
55
+
56
+ await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
38
57
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
58
 
40
59
 
41
- const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat) => {
60
+ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => {
42
61
  if (!skipEndChatSDK) {
43
62
  try {
44
63
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
@@ -52,8 +71,23 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
52
71
  exception: ex
53
72
  }
54
73
  });
74
+ postMessageToOtherTab = false;
55
75
  }
56
- }
76
+ } // Need to clear these states immediately when chat ended from OC.
77
+
78
+
79
+ dispatch({
80
+ type: LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
81
+ payload: undefined
82
+ });
83
+ dispatch({
84
+ type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
85
+ payload: undefined
86
+ });
87
+ dispatch({
88
+ type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
89
+ payload: undefined
90
+ });
57
91
 
58
92
  if (!skipCloseChat) {
59
93
  try {
@@ -82,16 +116,26 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
82
116
  payload: null
83
117
  });
84
118
  dispatch({
85
- type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
86
- payload: undefined
119
+ type: LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
120
+ payload: 0
87
121
  });
88
122
  dispatch({
89
- type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
90
- payload: undefined
91
- });
92
- BroadcastService.postMessage({
93
- eventName: BroadcastEvent.EndChat
123
+ type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
124
+ payload: {
125
+ proactiveChatBodyTitle: "",
126
+ proactiveChatEnablePrechat: false,
127
+ proactiveChatInNewWindow: false
128
+ }
94
129
  });
130
+
131
+ if (postMessageToOtherTab) {
132
+ var _chatSDK$omnichannelC, _chatSDK$omnichannelC2;
133
+
134
+ const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId);
135
+ BroadcastService.postMessage({
136
+ eventName: endChatEventName
137
+ });
138
+ }
95
139
  } catch (error) {
96
140
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
97
141
  Event: TelemetryEvent.CloseChatMethodException,
@@ -7,7 +7,7 @@ import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostC
7
7
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
8
8
  import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
9
9
  import attachmentProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware";
10
- import { changeLanguageCodeFormatForWebChat } from "../../../common/utils";
10
+ import { addDelayInMs, changeLanguageCodeFormatForWebChat } from "../../../common/utils";
11
11
  import channelDataMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware";
12
12
  import { createActivityMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware";
13
13
  import createAttachmentMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware";
@@ -26,10 +26,13 @@ import gifUploadMiddleware from "../../webchatcontainerstateful/webchatcontrolle
26
26
  import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware";
27
27
  import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
28
28
  import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
29
- import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
30
+ import { createCardActionMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware";
31
+ import createMessageTimeStampMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware";
32
+ import { Constants } from "../../../common/Constants"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
33
 
31
34
  export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
32
- var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21;
35
+ var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
33
36
 
34
37
  const localizedTexts = { ...defaultMiddlewareLocalizedTexts,
35
38
  ...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
@@ -63,6 +66,12 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
63
66
 
64
67
  if (isPostChatEnabled === "true") {
65
68
  if (postChatSurveyMode === PostChatSurveyMode.Embed) {
69
+ WebChatStoreLoader.store = null;
70
+ dispatch({
71
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
72
+ payload: ConversationState.PostchatLoading
73
+ });
74
+ await addDelayInMs(Constants.PostChatLoadingDurationInMs);
66
75
  const loadPostChatEvent = {
67
76
  eventName: BroadcastEvent.LoadPostChatSurvey
68
77
  };
@@ -84,10 +93,14 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
84
93
  type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
85
94
  payload: undefined
86
95
  });
96
+ dispatch({
97
+ type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
98
+ payload: undefined
99
+ });
87
100
  };
88
101
 
89
102
  webChatStore = createStore({}, //initial state
90
- preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), channelDataMiddleware, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware, createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware, // eslint-disable-next-line @typescript-eslint/no-explicit-any
103
+ preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), channelDataMiddleware, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), createMessageTimeStampMiddleware, gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware, createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware, // eslint-disable-next-line @typescript-eslint/no-explicit-any
91
104
  ...(((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.storeMiddlewares) ?? []));
92
105
  WebChatStoreLoader.store = webChatStore;
93
106
  } // Initialize the remaining Web Chat props
@@ -105,7 +118,8 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
105
118
  groupActivitiesMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
106
119
  typingIndicatorMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
107
120
  onTelemetry: createWebChatTelemetry(),
108
- ...((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.webChatProps)
121
+ cardActionMiddleware: createCardActionMiddleware(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
122
+ ...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
109
123
  };
110
124
  return webChatProps;
111
125
  };
@@ -29,9 +29,17 @@ const getChatReconnectContext = async (chatSDK, reconnectId) => {
29
29
 
30
30
 
31
31
  const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
32
- var _props$reconnectChatP, _props$reconnectChatP2;
32
+ var _props$chatConfig, _props$reconnectChatP;
33
33
 
34
- if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && (_props$reconnectChatP2 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP2 !== void 0 && _props$reconnectChatP2.authClientFunction // TODO: Implement this after storage is in place
34
+ let authClientFunction = undefined;
35
+
36
+ if ((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) {
37
+ var _props$chatConfig2, _props$chatConfig2$Li;
38
+
39
+ authClientFunction = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveChatConfigAuthSettings) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_javascriptclientfunction) ?? undefined;
40
+ }
41
+
42
+ if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && authClientFunction // TODO: Implement this after storage is in place
35
43
 
36
44
  /* && !isLoadWithState() */
37
45
  ) {
@@ -46,27 +54,27 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
46
54
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
55
 
48
56
 
49
- const handleUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
57
+ const handleUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
50
58
  const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
51
59
 
52
60
  if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
53
- await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
61
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
54
62
  } else {
55
- await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
63
+ await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
56
64
  }
57
65
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
66
 
59
67
 
60
- const startUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
68
+ const startUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat) => {
61
69
  const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
62
70
 
63
71
  if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
64
- await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
72
+ await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
65
73
  }
66
74
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
75
 
68
76
 
69
- const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
77
+ const setReconnectIdAndStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat) => {
70
78
  const startUnauthenticatedReconnectChat = {
71
79
  eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
72
80
  };
@@ -82,7 +90,7 @@ const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconne
82
90
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
83
91
  payload: ConversationState.Loading
84
92
  });
85
- await initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
93
+ await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, optionalParams);
86
94
  };
87
95
 
88
96
  const redirectPage = (redirectURL, redirectInSameWindow) => {
@@ -104,7 +112,7 @@ const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
104
112
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
113
 
106
114
 
107
- const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, initStartChat) => {
115
+ const startNewChatEmptyRedirectionUrl = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat) => {
108
116
  const startUnauthenticatedReconnectChat = {
109
117
  eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
110
118
  };
@@ -127,25 +135,25 @@ const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, in
127
135
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
128
136
  payload: ConversationState.Loading
129
137
  });
130
- await initStartChat(chatSDK, dispatch, setAdapter);
138
+ await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter);
131
139
  }
132
140
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
133
141
 
134
142
 
135
- const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
143
+ const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
136
144
  const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
137
145
 
138
146
  if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
139
- await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
147
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
140
148
  }
141
149
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
142
150
 
143
151
 
144
- const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
152
+ const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
145
153
  if (reconnectAvailabilityResponse.redirectURL) {
146
154
  redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
147
155
  } else {
148
- await startNewChatEmptyRedirectionUrl(chatSDK, dispatch, setAdapter, initStartChat);
156
+ await startNewChatEmptyRedirectionUrl(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat);
149
157
  }
150
158
  };
151
159
 
@@ -29,10 +29,6 @@ export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persist
29
29
 
30
30
 
31
31
  BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
32
- dispatch({
33
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
34
- payload: ConversationState.Loading
35
- });
36
32
  dispatch({
37
33
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
38
34
  payload: ConversationState.Postchat
@@ -0,0 +1,38 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
+ export function shareObservable(observable) {
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ let observers = []; // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+
6
+ let subscription; // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+
8
+ return new window.Observable(observer => {
9
+ if (!subscription) {
10
+ subscription = observable.subscribe({
11
+ complete() {
12
+ observers.forEach(observer => observer.complete());
13
+ },
14
+
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ error(err) {
17
+ observers.forEach(observer => observer.error(err));
18
+ },
19
+
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ next(value) {
22
+ observers.forEach(observer => observer.next(value));
23
+ }
24
+
25
+ });
26
+ }
27
+
28
+ observers.push(observer);
29
+ return () => {
30
+ observers = observers.filter(o => o !== observer);
31
+
32
+ if (!observers.length) {
33
+ subscription.unsubscribe();
34
+ subscription = null;
35
+ }
36
+ };
37
+ });
38
+ }