@microsoft/omnichannel-chat-widget 0.1.0-main.dbc1afa → 0.1.0-main.df02f14
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.
- package/README.md +32 -0
- package/lib/cjs/common/Constants.js +16 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +20 -2
- package/lib/cjs/common/utils.js +65 -6
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +19 -3
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +10 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -3
- package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
- package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +9 -3
- package/lib/cjs/components/livechatwidget/common/endChat.js +55 -23
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +16 -3
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +23 -15
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +169 -82
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +219 -91
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -8
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +3 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +3 -2
- package/lib/cjs/contexts/createReducer.js +16 -0
- package/lib/cjs/controller/componentController.js +3 -3
- package/lib/esm/common/Constants.js +16 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +20 -2
- package/lib/esm/common/utils.js +49 -4
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +21 -6
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -2
- package/lib/esm/components/headerstateful/HeaderStateful.js +4 -3
- package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
- package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +9 -3
- package/lib/esm/components/livechatwidget/common/endChat.js +56 -23
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +15 -5
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +23 -15
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +162 -81
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +213 -94
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -8
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +3 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +3 -2
- package/lib/esm/contexts/createReducer.js +16 -0
- package/lib/esm/controller/componentController.js +3 -3
- package/lib/types/common/Constants.d.ts +8 -0
- package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +20 -3
- package/lib/types/common/utils.d.ts +7 -3
- package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +4 -3
- package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
- package/lib/types/contexts/common/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +4 -1
- package/package.json +4 -3
package/lib/esm/common/utils.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AriaTelemetryConstants, Constants, LocaleConstants } from "./Constants";
|
|
2
|
+
import { DataStoreManager } from "./contextDataStore/DataStoreManager";
|
|
2
3
|
import { KeyCodes } from "./KeyCodes";
|
|
3
4
|
import { BroadcastEvent } from "./telemetry/TelemetryConstants";
|
|
5
|
+
import { Md5 } from "md5-typescript";
|
|
4
6
|
|
|
5
7
|
const getElementBySelector = selector => {
|
|
6
8
|
let element;
|
|
@@ -289,9 +291,52 @@ export const getDomain = hostValue => {
|
|
|
289
291
|
|
|
290
292
|
return AriaTelemetryConstants.Public;
|
|
291
293
|
};
|
|
292
|
-
export const getWidgetCacheId = (orgId, widgetId) => {
|
|
293
|
-
|
|
294
|
+
export const getWidgetCacheId = (orgId, widgetId, widgetInstanceId) => {
|
|
295
|
+
const widgetCacheId = `${widgetInstanceId}_${orgId}_${widgetId}`;
|
|
296
|
+
return Md5.init(widgetCacheId);
|
|
294
297
|
};
|
|
295
|
-
export const getWidgetEndChatEventName = (orgId, widgetId) => {
|
|
296
|
-
|
|
298
|
+
export const getWidgetEndChatEventName = (orgId, widgetId, widgetInstanceId) => {
|
|
299
|
+
if (!isNullOrEmptyString(widgetInstanceId)) {
|
|
300
|
+
return `${BroadcastEvent.ChatEnded}_${widgetInstanceId}_${orgId}_${widgetId}`;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return `${BroadcastEvent.ChatEnded}_${orgId}_${widgetId}`;
|
|
304
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
305
|
+
|
|
306
|
+
export const getStateFromCache = (orgId, widgetId, widgetInstanceId) => {
|
|
307
|
+
// Getting updated state from cache
|
|
308
|
+
try {
|
|
309
|
+
if (DataStoreManager.clientDataStore) {
|
|
310
|
+
var _DataStoreManager$cli;
|
|
311
|
+
|
|
312
|
+
const widgetStateEventName = getWidgetCacheId(orgId, widgetId, widgetInstanceId);
|
|
313
|
+
const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
|
|
314
|
+
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
315
|
+
return persistedState;
|
|
316
|
+
} else {
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
} catch (error) {
|
|
320
|
+
console.log(error);
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
324
|
+
|
|
325
|
+
export const isUndefinedOrEmpty = object => {
|
|
326
|
+
if (object) {
|
|
327
|
+
if (Object.keys(object).length === 0) {
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return false;
|
|
332
|
+
} else {
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
336
|
+
|
|
337
|
+
export const addDelayInMs = ms => {
|
|
338
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
339
|
+
};
|
|
340
|
+
export const getBroadcastChannelName = (widgetId, widgetInstanceId) => {
|
|
341
|
+
return widgetInstanceId && !isNullOrEmptyString(widgetInstanceId) ? `${widgetInstanceId}_${widgetId}` : widgetId;
|
|
297
342
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
2
|
-
import React, { useEffect, useState } from "react";
|
|
3
|
-
import { ChatButton } from "@microsoft/omnichannel-chat-components";
|
|
1
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
2
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { BroadcastService, ChatButton } from "@microsoft/omnichannel-chat-components";
|
|
4
4
|
import { Constants } from "../../common/Constants";
|
|
5
5
|
import { setFocusOnElement } from "../../common/utils";
|
|
6
6
|
import { ConversationState } from "../../contexts/common/ConversationState";
|
|
@@ -10,7 +10,7 @@ import { TelemetryTimers } from "../../common/telemetry/TelemetryManager";
|
|
|
10
10
|
import { defaultOutOfOfficeChatButtonStyleProps } from "./common/styleProps/defaultOutOfOfficeChatButtonStyleProps";
|
|
11
11
|
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
12
12
|
export const ChatButtonStateful = props => {
|
|
13
|
-
var _state$domainStates$l, _state$domainStates$l2, _buttonProps$controlP;
|
|
13
|
+
var _state$domainStates$l, _state$domainStates$l2, _buttonProps$controlP, _props$buttonProps, _props$buttonProps$co, _props$buttonProps2, _props$buttonProps2$c, _props$buttonProps3, _props$buttonProps3$c;
|
|
14
14
|
|
|
15
15
|
const [state, dispatch] = useChatContextStore();
|
|
16
16
|
const {
|
|
@@ -20,6 +20,7 @@ export const ChatButtonStateful = props => {
|
|
|
20
20
|
} = props; //Setting OutOfOperatingHours Flag
|
|
21
21
|
|
|
22
22
|
const [outOfOperatingHours, setOutOfOperatingHours] = useState(((_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.OutOfOperatingHours) === "True");
|
|
23
|
+
const proactiveChatInNewWindow = useRef(state.appStates.proactiveChatStates.proactiveChatInNewWindow);
|
|
23
24
|
const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
|
|
24
25
|
const controlProps = {
|
|
25
26
|
id: "oc-lcw-chat-button",
|
|
@@ -27,13 +28,18 @@ export const ChatButtonStateful = props => {
|
|
|
27
28
|
titleText: "Let's Chat!",
|
|
28
29
|
subtitleText: "We're online.",
|
|
29
30
|
hideNotificationBubble: (buttonProps === null || buttonProps === void 0 ? void 0 : (_buttonProps$controlP = buttonProps.controlProps) === null || _buttonProps$controlP === void 0 ? void 0 : _buttonProps$controlP.hideNotificationBubble) === true || state.appStates.isMinimized === false,
|
|
30
|
-
unreadMessageCount: state.appStates.unreadMessageCount ? state.appStates.unreadMessageCount > Constants.maximumUnreadMessageCount ?
|
|
31
|
+
unreadMessageCount: state.appStates.unreadMessageCount ? state.appStates.unreadMessageCount > Constants.maximumUnreadMessageCount ? (_props$buttonProps = props.buttonProps) === null || _props$buttonProps === void 0 ? void 0 : (_props$buttonProps$co = _props$buttonProps.controlProps) === null || _props$buttonProps$co === void 0 ? void 0 : _props$buttonProps$co.largeUnreadMessageString : state.appStates.unreadMessageCount.toString() : "0",
|
|
31
32
|
onClick: async () => {
|
|
32
33
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
33
34
|
Event: TelemetryEvent.LCWChatButtonClicked
|
|
34
35
|
});
|
|
35
36
|
|
|
36
|
-
if (
|
|
37
|
+
if (proactiveChatInNewWindow.current) {
|
|
38
|
+
const proactiveChatIsInPopoutModeEvent = {
|
|
39
|
+
eventName: BroadcastEvent.ProactiveChatIsInPopoutMode
|
|
40
|
+
};
|
|
41
|
+
BroadcastService.postMessage(proactiveChatIsInPopoutModeEvent);
|
|
42
|
+
} else if (state.appStates.isMinimized) {
|
|
37
43
|
dispatch({
|
|
38
44
|
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
39
45
|
payload: false
|
|
@@ -42,6 +48,7 @@ export const ChatButtonStateful = props => {
|
|
|
42
48
|
await startChat();
|
|
43
49
|
}
|
|
44
50
|
},
|
|
51
|
+
unreadMessageString: (_props$buttonProps2 = props.buttonProps) === null || _props$buttonProps2 === void 0 ? void 0 : (_props$buttonProps2$c = _props$buttonProps2.controlProps) === null || _props$buttonProps2$c === void 0 ? void 0 : _props$buttonProps2$c.unreadMessageString,
|
|
45
52
|
...(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.controlProps)
|
|
46
53
|
};
|
|
47
54
|
const outOfOfficeControlProps = {
|
|
@@ -50,6 +57,10 @@ export const ChatButtonStateful = props => {
|
|
|
50
57
|
titleText: "We're Offline",
|
|
51
58
|
subtitleText: "No agents available",
|
|
52
59
|
onClick: async () => {
|
|
60
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
61
|
+
Event: TelemetryEvent.LCWChatButtonClicked
|
|
62
|
+
});
|
|
63
|
+
|
|
53
64
|
if (state.appStates.isMinimized) {
|
|
54
65
|
dispatch({
|
|
55
66
|
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
@@ -62,6 +73,7 @@ export const ChatButtonStateful = props => {
|
|
|
62
73
|
});
|
|
63
74
|
}
|
|
64
75
|
},
|
|
76
|
+
unreadMessageString: (_props$buttonProps3 = props.buttonProps) === null || _props$buttonProps3 === void 0 ? void 0 : (_props$buttonProps3$c = _props$buttonProps3.controlProps) === null || _props$buttonProps3$c === void 0 ? void 0 : _props$buttonProps3$c.unreadMessageString,
|
|
65
77
|
...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
|
|
66
78
|
};
|
|
67
79
|
useEffect(() => {
|
|
@@ -83,6 +95,9 @@ export const ChatButtonStateful = props => {
|
|
|
83
95
|
});
|
|
84
96
|
}
|
|
85
97
|
}, []);
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
proactiveChatInNewWindow.current = state.appStates.proactiveChatStates.proactiveChatInNewWindow;
|
|
100
|
+
}, [state.appStates.proactiveChatStates.proactiveChatInNewWindow]);
|
|
86
101
|
return /*#__PURE__*/React.createElement(ChatButton, {
|
|
87
102
|
componentOverrides: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.componentOverrides,
|
|
88
103
|
controlProps: outOfOperatingHours ? outOfOfficeControlProps : controlProps,
|
|
@@ -17,7 +17,6 @@ export const ConfirmationPaneStateful = props => {
|
|
|
17
17
|
const {
|
|
18
18
|
prepareEndChat
|
|
19
19
|
} = props; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
20
|
|
|
22
21
|
const [adapter] = useChatAdapterStore();
|
|
23
22
|
const controlProps = {
|
package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -105,8 +105,14 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
105
105
|
let fileAttachmentName = TranscriptConstants.DefaultFileAttachmentName;
|
|
106
106
|
let dialogColor = TranscriptConstants.CustomerDialogColor;
|
|
107
107
|
let fontColor = TranscriptConstants.CustomerFontColor;
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
const isSystemMessage = value.tags && value.tags.toLowerCase().indexOf(Constants.systemMessageTag) !== -1;
|
|
109
|
+
const isControlMessage = value.isControlMessage && value.isControlMessage === true;
|
|
110
|
+
const isAdaptiveCard = value.contentType && value.contentType.toLowerCase() === TranscriptConstants.AdaptiveCardType;
|
|
111
|
+
const isInternalMessage = value.deliveryMode && value.deliveryMode.toLowerCase() === TranscriptConstants.InternalMode;
|
|
112
|
+
const isHiddenMessage = value.tags && value.tags.toLowerCase().indexOf(Constants.hiddenTag.toLowerCase()) !== -1;
|
|
113
|
+
const shouldIgnoreMessage = isSystemMessage || isControlMessage || isAdaptiveCard || isInternalMessage || isHiddenMessage;
|
|
114
|
+
|
|
115
|
+
if (shouldIgnoreMessage) {
|
|
110
116
|
return;
|
|
111
117
|
} else if (value.from) {
|
|
112
118
|
if (value.from.application) {
|
|
@@ -49,7 +49,8 @@ export const HeaderStateful = props => {
|
|
|
49
49
|
} else {
|
|
50
50
|
const skipEndChatSDK = true;
|
|
51
51
|
const skipCloseChat = false;
|
|
52
|
-
|
|
52
|
+
const postMessageToOtherTabs = true;
|
|
53
|
+
await endChat(adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTabs);
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
dispatch({
|
|
@@ -58,8 +59,8 @@ export const HeaderStateful = props => {
|
|
|
58
59
|
});
|
|
59
60
|
},
|
|
60
61
|
...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
|
|
61
|
-
hideTitle: state.appStates.conversationState === ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
62
|
-
hideIcon: state.appStates.conversationState === ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
|
|
62
|
+
hideTitle: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
63
|
+
hideIcon: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
|
|
63
64
|
hideCloseButton: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.Prechat || state.appStates.conversationState === ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
|
|
64
65
|
};
|
|
65
66
|
const outOfOfficeControlProps = {
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
import { Deferred } from "./Deferred";
|
|
4
|
+
export class ActivityStreamHandler {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Use of a deferred pattern, to hold the execution of the activity.
|
|
10
|
+
*
|
|
11
|
+
* */
|
|
12
|
+
static cork() {
|
|
13
|
+
ActivityStreamHandler.restoreDeferred = new Deferred();
|
|
14
|
+
ActivityStreamHandler.restorePromise = ActivityStreamHandler.restoreDeferred.promise;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the promise, releasing it to continue with the execution of the activity.
|
|
18
|
+
*
|
|
19
|
+
* */
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
static uncork() {
|
|
23
|
+
ActivityStreamHandler.restoreDeferred.resolve();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
_defineProperty(ActivityStreamHandler, "restoreDeferred", {
|
|
29
|
+
resolve: () => {
|
|
30
|
+
return "initialState";
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
_defineProperty(ActivityStreamHandler, "restorePromise", void 0);
|
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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 DefaultActivitySubscriber {
|
|
4
|
+
constructor() {
|
|
5
|
+
_defineProperty(this, "observer", void 0);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
async next(activity) {
|
|
10
|
+
this.observer.next(activity);
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
import { ActivityStreamHandler } from "../ActivityStreamHandler";
|
|
4
|
+
export class PauseActivitySubscriber {
|
|
5
|
+
constructor() {
|
|
6
|
+
_defineProperty(this, "observer", void 0);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
async apply(activity) {
|
|
11
|
+
await ActivityStreamHandler.restorePromise;
|
|
12
|
+
return activity;
|
|
13
|
+
} // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
applicable(activity) {
|
|
17
|
+
return true;
|
|
18
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
async next(activity) {
|
|
22
|
+
if (this.applicable(activity)) {
|
|
23
|
+
return await this.apply(activity);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return activity;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
import { DefaultActivitySubscriber } from "./ActivitySubscriber/DefaultActivitySubscriber";
|
|
4
|
+
import { shareObservable } from "./shareObservable";
|
|
5
|
+
export class ChatAdapterShim {
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
constructor(chatAdapter) {
|
|
11
|
+
_defineProperty(this, "chatAdapter", void 0);
|
|
12
|
+
|
|
13
|
+
_defineProperty(this, "activityObserver", void 0);
|
|
14
|
+
|
|
15
|
+
_defineProperty(this, "subscribers", void 0);
|
|
16
|
+
|
|
17
|
+
this.subscribers = [];
|
|
18
|
+
this.chatAdapter = { ...chatAdapter,
|
|
19
|
+
activity$: shareObservable( // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
new window.Observable(observer => {
|
|
21
|
+
this.activityObserver = observer; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
|
|
23
|
+
const abortController = new window.AbortController();
|
|
24
|
+
|
|
25
|
+
(async () => {
|
|
26
|
+
try {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
for await (let activity of chatAdapter.activities({
|
|
29
|
+
signal: abortController.signal
|
|
30
|
+
})) {
|
|
31
|
+
for (const subscriber of [...this.subscribers, new DefaultActivitySubscriber()]) {
|
|
32
|
+
subscriber.observer = this.activityObserver;
|
|
33
|
+
activity = await subscriber.next(activity);
|
|
34
|
+
|
|
35
|
+
if (!activity) {
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
observer.complete();
|
|
42
|
+
} catch (error) {
|
|
43
|
+
observer.error(error);
|
|
44
|
+
}
|
|
45
|
+
})();
|
|
46
|
+
|
|
47
|
+
return () => {
|
|
48
|
+
abortController.abort();
|
|
49
|
+
};
|
|
50
|
+
}))
|
|
51
|
+
};
|
|
52
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
addSubscriber(subscriber) {
|
|
56
|
+
this.subscribers.push(subscriber);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
}
|
|
@@ -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";
|
|
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
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
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 (
|
|
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(``, 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
|
-
}
|
|
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
|
};
|
|
@@ -316,7 +316,9 @@ export const dummyDefaultProps = {
|
|
|
316
316
|
hideChatTextContainer: false,
|
|
317
317
|
hideChatSubtitle: false,
|
|
318
318
|
hideChatTitle: false,
|
|
319
|
-
hideNotificationBubble: true
|
|
319
|
+
hideNotificationBubble: true,
|
|
320
|
+
unreadMessageString: "new messages",
|
|
321
|
+
largeUnreadMessageString: "99+"
|
|
320
322
|
},
|
|
321
323
|
styleProps: {
|
|
322
324
|
generalStyleProps: {
|
|
@@ -1411,7 +1413,6 @@ export const dummyDefaultProps = {
|
|
|
1411
1413
|
startNewChatButtonClassName: undefined
|
|
1412
1414
|
}
|
|
1413
1415
|
},
|
|
1414
|
-
authClientFunction: undefined,
|
|
1415
1416
|
isReconnectEnabled: undefined,
|
|
1416
1417
|
reconnectId: undefined,
|
|
1417
1418
|
redirectInSameWindow: undefined
|
|
@@ -1676,7 +1677,12 @@ export const dummyDefaultProps = {
|
|
|
1676
1677
|
MIDDLEWARE_MESSAGE_RETRY: "Retry",
|
|
1677
1678
|
PRECHAT_REQUIRED_FIELD_MISSING_MESSAGE: "{0} field is required",
|
|
1678
1679
|
MARKDOWN_EXTERNAL_LINK_ALT: "Opens in a new window; external."
|
|
1680
|
+
},
|
|
1681
|
+
botMagicCode: {
|
|
1682
|
+
disabled: false,
|
|
1683
|
+
fwdUrl: ""
|
|
1679
1684
|
}
|
|
1680
1685
|
},
|
|
1681
|
-
telemetryConfig: undefined
|
|
1686
|
+
telemetryConfig: undefined,
|
|
1687
|
+
getAuthToken: undefined
|
|
1682
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 { getWidgetEndChatEventName } from "../../../common/utils"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
import { addDelayInMs, getWidgetEndChatEventName } from "../../../common/utils"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
11
|
|
|
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
|
-
|
|
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, false);
|
|
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,9 +49,11 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
32
49
|
payload: ConversationState.InActive
|
|
33
50
|
});
|
|
34
51
|
}
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
|
@@ -44,16 +63,7 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
44
63
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
45
64
|
Event: TelemetryEvent.EndChatSDKCall
|
|
46
65
|
});
|
|
47
|
-
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
|
|
48
|
-
|
|
49
|
-
dispatch({
|
|
50
|
-
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
51
|
-
payload: undefined
|
|
52
|
-
});
|
|
53
|
-
dispatch({
|
|
54
|
-
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
55
|
-
payload: undefined
|
|
56
|
-
});
|
|
66
|
+
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
|
|
57
67
|
} catch (ex) {
|
|
58
68
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
59
69
|
Event: TelemetryEvent.EndChatSDKCallFailed,
|
|
@@ -63,7 +73,21 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
63
73
|
});
|
|
64
74
|
postMessageToOtherTab = false;
|
|
65
75
|
}
|
|
66
|
-
}
|
|
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
|
+
});
|
|
67
91
|
|
|
68
92
|
if (!skipCloseChat) {
|
|
69
93
|
try {
|
|
@@ -91,14 +115,23 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
91
115
|
type: LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
|
|
92
116
|
payload: null
|
|
93
117
|
});
|
|
94
|
-
|
|
95
|
-
|
|
118
|
+
dispatch({
|
|
119
|
+
type: LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
120
|
+
payload: 0
|
|
121
|
+
});
|
|
122
|
+
dispatch({
|
|
123
|
+
type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
124
|
+
payload: {
|
|
125
|
+
proactiveChatBodyTitle: "",
|
|
126
|
+
proactiveChatEnablePrechat: false,
|
|
127
|
+
proactiveChatInNewWindow: false
|
|
128
|
+
}
|
|
96
129
|
});
|
|
97
130
|
|
|
98
131
|
if (postMessageToOtherTab) {
|
|
99
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2;
|
|
132
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps;
|
|
100
133
|
|
|
101
|
-
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);
|
|
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, (props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.widgetInstanceId) ?? "");
|
|
102
135
|
BroadcastService.postMessage({
|
|
103
136
|
eventName: endChatEventName
|
|
104
137
|
});
|