@microsoft/omnichannel-chat-widget 0.1.0-main.592da7b → 0.1.0-main.60c3e17
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/lib/cjs/common/Constants.js +4 -0
- package/lib/cjs/common/storage/default/defaultCacheManager.js +34 -0
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +114 -0
- package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +86 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +19 -0
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +31 -18
- package/lib/cjs/common/utils.js +64 -5
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +4 -5
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +4 -4
- package/lib/cjs/components/footerstateful/FooterStateful.js +5 -13
- package/lib/cjs/components/headerstateful/HeaderStateful.js +14 -7
- 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/authHelper.js +65 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
- package/lib/cjs/components/livechatwidget/common/createFooter.js +7 -16
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +12 -0
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +51 -19
- package/lib/cjs/components/livechatwidget/common/endChat.js +52 -24
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +12 -0
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +55 -35
- 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 +135 -83
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +188 -108
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +6 -4
- package/lib/cjs/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -8
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +20 -4
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -1
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +13 -6
- package/lib/cjs/contexts/createReducer.js +10 -2
- package/lib/cjs/controller/componentController.js +2 -2
- package/lib/esm/common/Constants.js +4 -0
- package/lib/esm/common/storage/default/defaultCacheManager.js +19 -0
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +102 -0
- package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +71 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +19 -0
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +29 -13
- package/lib/esm/common/utils.js +48 -3
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +4 -5
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +4 -4
- package/lib/esm/components/footerstateful/FooterStateful.js +5 -13
- package/lib/esm/components/headerstateful/HeaderStateful.js +14 -7
- 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/authHelper.js +50 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
- package/lib/esm/components/livechatwidget/common/createFooter.js +4 -15
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +8 -0
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +51 -19
- package/lib/esm/components/livechatwidget/common/endChat.js +53 -25
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -2
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +56 -37
- 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 +131 -83
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +188 -110
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +5 -4
- package/lib/esm/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -8
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +15 -2
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -1
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +11 -6
- package/lib/esm/contexts/createReducer.js +10 -2
- package/lib/esm/controller/componentController.js +2 -2
- package/lib/types/common/Constants.d.ts +2 -0
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
- package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +11 -2
- 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/authHelper.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
- package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -3
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +3 -2
- package/lib/types/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.d.ts +2 -2
- package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +4 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
- package/lib/types/contexts/common/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -2
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -2
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
- package/package.json +5 -4
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
3
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
4
|
-
import { BroadcastService, decodeComponentString } from "@microsoft/omnichannel-chat-components";
|
|
4
|
+
import { BroadcastService, decodeComponentString, BroadcastServiceInitialize } from "@microsoft/omnichannel-chat-components";
|
|
5
5
|
import { Stack } from "@fluentui/react";
|
|
6
6
|
import React, { useEffect, useRef, useState } from "react";
|
|
7
|
-
import { createTimer, getLocaleDirection, getWidgetCacheId, getWidgetEndChatEventName } from "../../../common/utils";
|
|
7
|
+
import { createTimer, getBroadcastChannelName, getLocaleDirection, getStateFromCache, getWidgetCacheId, getWidgetEndChatEventName, isNullOrEmptyString, isUndefinedOrEmpty } from "../../../common/utils";
|
|
8
8
|
import { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat } from "../common/reconnectChatHelper";
|
|
9
|
-
import { initStartChat, prepareStartChat,
|
|
9
|
+
import { initStartChat, prepareStartChat, setPreChatAndInitiateChat } from "../common/startChat";
|
|
10
10
|
import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
|
|
11
11
|
import CallingContainerStateful from "../../callingcontainerstateful/CallingContainerStateful";
|
|
12
12
|
import ChatButtonStateful from "../../chatbuttonstateful/ChatButtonStateful";
|
|
@@ -43,8 +43,11 @@ import { startProactiveChat } from "../common/startProactiveChat";
|
|
|
43
43
|
import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
44
44
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
45
45
|
import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
46
|
+
import { ActivityStreamHandler } from "../common/ActivityStreamHandler";
|
|
47
|
+
import { registerBroadcastServiceForLocalStorage } from "../../../common/storage/default/defaultCacheManager";
|
|
48
|
+
import { defaultClientDataStoreProvider } from "../../../common/storage/default/defaultClientDataStoreProvider";
|
|
46
49
|
export const LiveChatWidgetStateful = props => {
|
|
47
|
-
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$
|
|
50
|
+
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps14, _props$controlProps15, _props$componentOverr, _props$controlProps16, _props$componentOverr2, _props$controlProps17, _props$componentOverr3, _props$controlProps18, _props$componentOverr4, _props$controlProps19, _props$componentOverr5, _props$controlProps20, _props$componentOverr6, _props$controlProps21, _props$componentOverr7, _props$controlProps22, _props$controlProps23, _props$componentOverr8, _props$controlProps24, _props$componentOverr9, _props$controlProps25, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
48
51
|
|
|
49
52
|
const [state, dispatch] = useChatContextStore(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
53
|
|
|
@@ -59,102 +62,146 @@ export const LiveChatWidgetStateful = props => {
|
|
|
59
62
|
const {
|
|
60
63
|
Composer
|
|
61
64
|
} = Components;
|
|
62
|
-
const canStartProactiveChat = useRef(true);
|
|
63
|
-
const canEndChat = useRef(true); // Process general styles
|
|
65
|
+
const canStartProactiveChat = useRef(true); // Process general styles
|
|
64
66
|
|
|
65
67
|
const generalStyles = {
|
|
66
68
|
root: Object.assign({}, getGeneralStylesForButton(state), (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyles)
|
|
67
69
|
};
|
|
70
|
+
const broadcastServiceChannelName = getBroadcastChannelName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.widgetId, ((_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.widgetInstanceId) ?? "");
|
|
71
|
+
BroadcastServiceInitialize(broadcastServiceChannelName);
|
|
68
72
|
TelemetryTimers.LcwLoadToChatButtonTimer = createTimer();
|
|
69
|
-
const widgetElementId = ((_props$
|
|
73
|
+
const widgetElementId = ((_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.id) || "oc-lcw";
|
|
70
74
|
const currentMessageCountRef = useRef(0);
|
|
71
75
|
let widgetStateEventName = "";
|
|
72
76
|
|
|
73
77
|
const initiateEndChatOnBrowserUnload = () => {
|
|
74
78
|
var _DataStoreManager$cli;
|
|
75
79
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
} // Clean local storage
|
|
82
|
-
|
|
80
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
81
|
+
Event: TelemetryEvent.BrowserUnloadEventStarted,
|
|
82
|
+
Description: "Browser unload event received."
|
|
83
|
+
});
|
|
84
|
+
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false); // Clean local storage
|
|
83
85
|
|
|
84
|
-
(_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage");
|
|
85
|
-
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
+
(_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage"); //Dispose calling instance
|
|
86
87
|
|
|
88
|
+
if (voiceVideoCallingSDK) {
|
|
89
|
+
voiceVideoCallingSDK === null || voiceVideoCallingSDK === void 0 ? void 0 : voiceVideoCallingSDK.close();
|
|
90
|
+
} //Message for clearing window[popouTab]
|
|
87
91
|
|
|
88
|
-
const getStateFromCache = () => {
|
|
89
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli2;
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
95
|
-
return persistedState;
|
|
93
|
+
BroadcastService.postMessage({
|
|
94
|
+
eventName: BroadcastEvent.ClosePopoutWindow
|
|
95
|
+
});
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
useEffect(() => {
|
|
99
|
-
var _props$
|
|
99
|
+
var _props$controlProps4, _props$controlProps5, _props$controlProps6, _props$controlProps8, _props$chatConfig, _props$chatConfig$Cha, _props$controlProps9, _props$reconnectChatP, _props$chatConfig2, _props$chatConfig2$Li, _props$reconnectChatP4, _state$domainStates;
|
|
100
|
+
|
|
101
|
+
// Add default localStorage support for widget
|
|
102
|
+
if (props.contextDataStore === undefined) {
|
|
103
|
+
var _chatSDK$omnichannelC2, _chatSDK$omnichannelC3, _props$controlProps3;
|
|
104
|
+
|
|
105
|
+
registerBroadcastServiceForLocalStorage(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.widgetInstanceId) ?? "");
|
|
106
|
+
DataStoreManager.clientDataStore = defaultClientDataStoreProvider();
|
|
107
|
+
} else {
|
|
108
|
+
DataStoreManager.clientDataStore = props.contextDataStore;
|
|
109
|
+
}
|
|
100
110
|
|
|
101
111
|
registerTelemetryLoggers(props, dispatch);
|
|
102
112
|
createInternetConnectionChangeHandler();
|
|
103
|
-
DataStoreManager.clientDataStore = props.contextDataStore ?? undefined;
|
|
104
113
|
dispatch({
|
|
105
114
|
type: LiveChatWidgetActionType.SET_WIDGET_ELEMENT_ID,
|
|
106
115
|
payload: widgetElementId
|
|
107
116
|
});
|
|
108
117
|
dispatch({
|
|
109
118
|
type: LiveChatWidgetActionType.SET_SKIP_CHAT_BUTTON_RENDERING,
|
|
110
|
-
payload: ((_props$
|
|
119
|
+
payload: ((_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.skipChatButtonRendering) || false
|
|
111
120
|
});
|
|
112
121
|
dispatch({
|
|
113
122
|
type: LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
114
123
|
payload: false
|
|
115
124
|
});
|
|
125
|
+
|
|
126
|
+
if ((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.widgetInstanceId && !isNullOrEmptyString((_props$controlProps6 = props.controlProps) === null || _props$controlProps6 === void 0 ? void 0 : _props$controlProps6.widgetInstanceId)) {
|
|
127
|
+
var _props$controlProps7;
|
|
128
|
+
|
|
129
|
+
dispatch({
|
|
130
|
+
type: LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID,
|
|
131
|
+
payload: (_props$controlProps7 = props.controlProps) === null || _props$controlProps7 === void 0 ? void 0 : _props$controlProps7.widgetInstanceId
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
116
135
|
initCallingSdk(chatSDK, setVoiceVideoCallingSDK).then(sdkCreated => {
|
|
117
136
|
sdkCreated && dispatch({
|
|
118
137
|
type: LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
119
138
|
payload: true
|
|
120
139
|
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
if (!((_props$controlProps3 = props.controlProps) !== null && _props$controlProps3 !== void 0 && _props$controlProps3.skipChatButtonRendering) && (_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
|
|
124
|
-
var _props$reconnectChatP2;
|
|
125
|
-
|
|
126
|
-
startUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, initStartChat);
|
|
127
|
-
} // Initialize global dir
|
|
128
|
-
|
|
140
|
+
}); // Initialize global dir
|
|
129
141
|
|
|
130
|
-
const globalDir = ((_props$
|
|
142
|
+
const globalDir = ((_props$controlProps8 = props.controlProps) === null || _props$controlProps8 === void 0 ? void 0 : _props$controlProps8.dir) ?? getLocaleDirection((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Cha = _props$chatConfig.ChatWidgetLanguage) === null || _props$chatConfig$Cha === void 0 ? void 0 : _props$chatConfig$Cha.msdyn_localeid);
|
|
131
143
|
dispatch({
|
|
132
144
|
type: LiveChatWidgetActionType.SET_GLOBAL_DIR,
|
|
133
145
|
payload: globalDir
|
|
134
146
|
});
|
|
135
147
|
|
|
136
|
-
if ((
|
|
148
|
+
if (!((_props$controlProps9 = props.controlProps) !== null && _props$controlProps9 !== void 0 && _props$controlProps9.skipChatButtonRendering) && (_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
|
|
149
|
+
var _props$reconnectChatP2, _props$reconnectChatP3;
|
|
150
|
+
|
|
151
|
+
startUnauthenticatedReconnectChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.isReconnectEnabled, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.reconnectId, initStartChat);
|
|
152
|
+
return;
|
|
153
|
+
} // Checks if reconnectId is present for auth chat. If it is present, then it shows reconnect chat pane,
|
|
154
|
+
// where customer can choose to continue previous conversation or start new conversation
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
const isAuthenticationSettingsEnabled = (_props$chatConfig2 = props.chatConfig) !== null && _props$chatConfig2 !== void 0 && (_props$chatConfig2$Li = _props$chatConfig2.LiveChatConfigAuthSettings) !== null && _props$chatConfig2$Li !== void 0 && _props$chatConfig2$Li.msdyn_javascriptclientfunction ? true : false;
|
|
159
|
+
|
|
160
|
+
if (!state.appStates.skipChatButtonRendering && state.appStates.conversationState === ConversationState.Active && isAuthenticationSettingsEnabled === true && (_props$reconnectChatP4 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP4 !== void 0 && _props$reconnectChatP4.isReconnectEnabled) {
|
|
161
|
+
getReconnectIdForAuthenticatedChat(props, chatSDK).then(authReconnectId => {
|
|
162
|
+
if (authReconnectId && !state.appStates.reconnectId) {
|
|
163
|
+
dispatch({
|
|
164
|
+
type: LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
165
|
+
payload: authReconnectId
|
|
166
|
+
});
|
|
167
|
+
dispatch({
|
|
168
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
169
|
+
payload: ConversationState.ReconnectChat
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (!state.appStates.skipChatButtonRendering && !isUndefinedOrEmpty((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext) && state.appStates.conversationState === ConversationState.Active) {
|
|
137
177
|
var _state$domainStates2;
|
|
138
178
|
|
|
139
179
|
const optionalParams = {
|
|
140
180
|
liveChatContext: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
|
|
141
181
|
};
|
|
142
|
-
initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
|
|
143
|
-
|
|
182
|
+
initStartChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams);
|
|
183
|
+
return;
|
|
184
|
+
} // All other case should show start chat button, skipChatButtonRendering will take care of it own
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
dispatch({
|
|
188
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
189
|
+
payload: ConversationState.Closed
|
|
190
|
+
});
|
|
144
191
|
}, []); // useEffect for when skip chat button rendering
|
|
145
192
|
|
|
146
193
|
useEffect(() => {
|
|
147
194
|
if (state.appStates.skipChatButtonRendering) {
|
|
148
|
-
var _props$
|
|
195
|
+
var _props$reconnectChatP5;
|
|
149
196
|
|
|
150
197
|
BroadcastService.postMessage({
|
|
151
198
|
eventName: BroadcastEvent.ChatInitiated
|
|
152
199
|
});
|
|
153
200
|
|
|
154
|
-
if ((_props$
|
|
155
|
-
var _props$
|
|
201
|
+
if ((_props$reconnectChatP5 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP5 !== void 0 && _props$reconnectChatP5.reconnectId && !state.appStates.reconnectId) {
|
|
202
|
+
var _props$reconnectChatP6, _props$reconnectChatP7, _props$reconnectChatP8;
|
|
156
203
|
|
|
157
|
-
handleUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, (_props$
|
|
204
|
+
handleUnauthenticatedReconnectChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, (_props$reconnectChatP6 = props.reconnectChatPaneProps) === null || _props$reconnectChatP6 === void 0 ? void 0 : _props$reconnectChatP6.isReconnectEnabled, (_props$reconnectChatP7 = props.reconnectChatPaneProps) === null || _props$reconnectChatP7 === void 0 ? void 0 : _props$reconnectChatP7.reconnectId, initStartChat, (_props$reconnectChatP8 = props.reconnectChatPaneProps) === null || _props$reconnectChatP8 === void 0 ? void 0 : _props$reconnectChatP8.redirectInSameWindow);
|
|
158
205
|
} else {
|
|
159
206
|
getReconnectIdForAuthenticatedChat(props, chatSDK).then(authReconnectId => {
|
|
160
207
|
if (authReconnectId && !state.appStates.reconnectId) {
|
|
@@ -167,11 +214,23 @@ export const LiveChatWidgetStateful = props => {
|
|
|
167
214
|
payload: ConversationState.ReconnectChat
|
|
168
215
|
});
|
|
169
216
|
} else {
|
|
217
|
+
var _state$domainStates3;
|
|
218
|
+
|
|
170
219
|
const chatStartedSkippingChatButtonRendering = {
|
|
171
220
|
eventName: BroadcastEvent.StartChatSkippingChatButtonRendering
|
|
172
221
|
};
|
|
173
222
|
BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
|
|
174
|
-
|
|
223
|
+
|
|
224
|
+
if (!isUndefinedOrEmpty((_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : _state$domainStates3.liveChatContext) && state.appStates.conversationState === ConversationState.Active) {
|
|
225
|
+
var _state$domainStates4;
|
|
226
|
+
|
|
227
|
+
const optionalParams = {
|
|
228
|
+
liveChatContext: (_state$domainStates4 = state.domainStates) === null || _state$domainStates4 === void 0 ? void 0 : _state$domainStates4.liveChatContext
|
|
229
|
+
};
|
|
230
|
+
initStartChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams);
|
|
231
|
+
} else {
|
|
232
|
+
setPreChatAndInitiateChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter);
|
|
233
|
+
}
|
|
175
234
|
}
|
|
176
235
|
});
|
|
177
236
|
}
|
|
@@ -179,7 +238,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
179
238
|
}, [state.appStates.skipChatButtonRendering]); // useEffect for when skip chat button rendering
|
|
180
239
|
|
|
181
240
|
useEffect(() => {
|
|
182
|
-
var _chatSDK$
|
|
241
|
+
var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$controlProps12;
|
|
183
242
|
|
|
184
243
|
// Add the custom context on receiving the SetCustomContext event
|
|
185
244
|
BroadcastService.getMessageByEventName(BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
@@ -198,7 +257,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
198
257
|
Description: "Start proactive chat event received."
|
|
199
258
|
});
|
|
200
259
|
|
|
201
|
-
if (canStartProactiveChat.current) {
|
|
260
|
+
if (canStartProactiveChat.current === true) {
|
|
202
261
|
var _msg$payload, _msg$payload2, _msg$payload3;
|
|
203
262
|
|
|
204
263
|
startProactiveChat(dispatch, msg === null || msg === void 0 ? void 0 : (_msg$payload = msg.payload) === null || _msg$payload === void 0 ? void 0 : _msg$payload.notificationConfig, msg === null || msg === void 0 ? void 0 : (_msg$payload2 = msg.payload) === null || _msg$payload2 === void 0 ? void 0 : _msg$payload2.enablePreChat, msg === null || msg === void 0 ? void 0 : (_msg$payload3 = msg.payload) === null || _msg$payload3 === void 0 ? void 0 : _msg$payload3.inNewWindow);
|
|
@@ -211,28 +270,36 @@ export const LiveChatWidgetStateful = props => {
|
|
|
211
270
|
}); // Start chat from SDK Event
|
|
212
271
|
|
|
213
272
|
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(() => {
|
|
273
|
+
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$controlProps10;
|
|
274
|
+
|
|
214
275
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
215
276
|
Event: TelemetryEvent.StartChatEventRecevied,
|
|
216
277
|
Description: "Start chat event received."
|
|
217
278
|
});
|
|
218
|
-
const persistedState = getStateFromCache();
|
|
279
|
+
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC5 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC5 === void 0 ? void 0 : _chatSDK$omnichannelC5.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps10 = props.controlProps) === null || _props$controlProps10 === void 0 ? void 0 : _props$controlProps10.widgetInstanceId) ?? ""); // Chat not found in cache
|
|
219
280
|
|
|
220
|
-
if (persistedState
|
|
221
|
-
// Embedded mode
|
|
222
|
-
BroadcastService.postMessage({
|
|
223
|
-
eventName: BroadcastEvent.ChatInitiated
|
|
224
|
-
});
|
|
225
|
-
prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
|
|
226
|
-
} else if (!persistedState) {
|
|
227
|
-
// Popout chat
|
|
281
|
+
if (persistedState === undefined) {
|
|
228
282
|
BroadcastService.postMessage({
|
|
229
283
|
eventName: BroadcastEvent.ChatInitiated
|
|
230
284
|
});
|
|
231
285
|
prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
|
|
232
|
-
|
|
286
|
+
return;
|
|
287
|
+
} // Chat exist in cache
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
if (persistedState) {
|
|
233
291
|
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4;
|
|
234
292
|
|
|
235
|
-
//
|
|
293
|
+
// Only initiate new chat if widget state in cache in one of the followings
|
|
294
|
+
if (persistedState.appStates.conversationState === ConversationState.Closed || persistedState.appStates.conversationState === ConversationState.InActive || persistedState.appStates.conversationState === ConversationState.Postchat) {
|
|
295
|
+
BroadcastService.postMessage({
|
|
296
|
+
eventName: BroadcastEvent.ChatInitiated
|
|
297
|
+
});
|
|
298
|
+
prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
|
|
299
|
+
return;
|
|
300
|
+
} // If minimized, maximize the chat
|
|
301
|
+
|
|
302
|
+
|
|
236
303
|
dispatch({
|
|
237
304
|
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
238
305
|
payload: false
|
|
@@ -248,49 +315,39 @@ export const LiveChatWidgetStateful = props => {
|
|
|
248
315
|
}); // End chat
|
|
249
316
|
|
|
250
317
|
BroadcastService.getMessageByEventName(BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
251
|
-
if (
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
|
|
318
|
+
if (state.appStates.skipChatButtonRendering !== true) {
|
|
319
|
+
var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$controlProps11;
|
|
320
|
+
|
|
321
|
+
// This is to ensure to get latest state from cache in multitab
|
|
322
|
+
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
323
|
+
|
|
324
|
+
if (persistedState && persistedState.appStates.conversationState === ConversationState.Active) {
|
|
325
|
+
prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
326
|
+
} else {
|
|
327
|
+
const skipEndChatSDK = true;
|
|
328
|
+
const skipCloseChat = false;
|
|
329
|
+
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
|
|
330
|
+
}
|
|
257
331
|
}
|
|
258
332
|
|
|
259
333
|
BroadcastService.postMessage({
|
|
260
334
|
eventName: BroadcastEvent.CloseChat
|
|
261
335
|
});
|
|
262
|
-
});
|
|
336
|
+
}); // End chat on browser unload
|
|
337
|
+
|
|
263
338
|
BroadcastService.getMessageByEventName(BroadcastEvent.InitiateEndChatOnBrowserUnload).subscribe(() => {
|
|
264
339
|
initiateEndChatOnBrowserUnload();
|
|
265
|
-
}); // reset proactive chat params
|
|
266
|
-
|
|
267
|
-
BroadcastService.getMessageByEventName(BroadcastEvent.ResetProactiveChatParams).subscribe(async () => {
|
|
268
|
-
dispatch({
|
|
269
|
-
type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
270
|
-
payload: {
|
|
271
|
-
proactiveChatBodyTitle: "",
|
|
272
|
-
proactiveChatEnablePrechat: false,
|
|
273
|
-
proactiveChatInNewWindow: false
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
340
|
}); // Listen to end chat event from other tabs
|
|
277
341
|
|
|
278
|
-
const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$
|
|
342
|
+
const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC8 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC8 === void 0 ? void 0 : _chatSDK$omnichannelC8.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC9 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC9 === void 0 ? void 0 : _chatSDK$omnichannelC9.widgetId, ((_props$controlProps12 = props.controlProps) === null || _props$controlProps12 === void 0 ? void 0 : _props$controlProps12.widgetInstanceId) ?? "");
|
|
279
343
|
BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
280
344
|
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
window.addEventListener("beforeunload", () => {
|
|
284
|
-
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
285
|
-
Event: TelemetryEvent.WindowClosed,
|
|
286
|
-
Description: "Closed window."
|
|
287
|
-
});
|
|
288
|
-
disposeTelemetryLoggers();
|
|
289
|
-
});
|
|
345
|
+
return;
|
|
346
|
+
}); // When conversation ended by agent
|
|
290
347
|
|
|
291
348
|
if (state.appStates.conversationEndedByAgent) {
|
|
292
349
|
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
|
|
293
|
-
} //Listen to WidgetSize
|
|
350
|
+
} //Listen to WidgetSize, used for minimize to maximize
|
|
294
351
|
|
|
295
352
|
|
|
296
353
|
BroadcastService.getMessageByEventName("WidgetSize").subscribe(msg => {
|
|
@@ -299,25 +356,23 @@ export const LiveChatWidgetStateful = props => {
|
|
|
299
356
|
payload: msg === null || msg === void 0 ? void 0 : msg.payload
|
|
300
357
|
});
|
|
301
358
|
});
|
|
359
|
+
return () => {
|
|
360
|
+
disposeTelemetryLoggers();
|
|
361
|
+
};
|
|
302
362
|
}, []);
|
|
303
363
|
useEffect(() => {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
if (state.appStates.conversationState === ConversationState.Active) {
|
|
307
|
-
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
|
|
308
|
-
BroadcastService.postMessage({
|
|
309
|
-
eventName: BroadcastEvent.NewMessageNotification
|
|
310
|
-
});
|
|
311
|
-
});
|
|
312
|
-
} // Track the message count
|
|
313
|
-
|
|
314
|
-
|
|
364
|
+
// On new message
|
|
315
365
|
if (state.appStates.conversationState === ConversationState.Active) {
|
|
316
366
|
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
|
|
367
|
+
// Track the message count
|
|
317
368
|
currentMessageCountRef.current++;
|
|
318
369
|
dispatch({
|
|
319
370
|
type: LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
320
371
|
payload: currentMessageCountRef.current + 1
|
|
372
|
+
}); // New message notification
|
|
373
|
+
|
|
374
|
+
BroadcastService.postMessage({
|
|
375
|
+
eventName: BroadcastEvent.NewMessageNotification
|
|
321
376
|
});
|
|
322
377
|
});
|
|
323
378
|
}
|
|
@@ -327,6 +382,12 @@ export const LiveChatWidgetStateful = props => {
|
|
|
327
382
|
}, [state.appStates.conversationState, state.appStates.proactiveChatStates.proactiveChatInNewWindow]); // Reset the UnreadMessageCount when minimized is toggled and broadcast it.
|
|
328
383
|
|
|
329
384
|
useEffect(() => {
|
|
385
|
+
if (state.appStates.isMinimized) {
|
|
386
|
+
ActivityStreamHandler.cork();
|
|
387
|
+
} else {
|
|
388
|
+
setTimeout(() => ActivityStreamHandler.uncork(), 500);
|
|
389
|
+
}
|
|
390
|
+
|
|
330
391
|
currentMessageCountRef.current = -1;
|
|
331
392
|
dispatch({
|
|
332
393
|
type: LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
@@ -359,9 +420,26 @@ export const LiveChatWidgetStateful = props => {
|
|
|
359
420
|
}, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]); // Publish chat widget state
|
|
360
421
|
|
|
361
422
|
useEffect(() => {
|
|
362
|
-
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic;
|
|
363
|
-
|
|
364
|
-
|
|
423
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps13;
|
|
424
|
+
|
|
425
|
+
// Only activate these windows events when conversation state is active and chat widget is in popout mode
|
|
426
|
+
// Ghost chat scenarios
|
|
427
|
+
|
|
428
|
+
/* COMMENTING THIS CODE FOR PARITY WITH OLD LCW
|
|
429
|
+
if (state.appStates.conversationState === ConversationState.Active &&
|
|
430
|
+
props.controlProps?.skipChatButtonRendering === true) {
|
|
431
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
432
|
+
|
|
433
|
+
window.onbeforeunload = function () {
|
|
434
|
+
const prompt = Constants.BrowserUnloadConfirmationMessage;
|
|
435
|
+
return prompt;
|
|
436
|
+
};
|
|
437
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
438
|
+
window.onunload = function () {
|
|
439
|
+
initiateEndChatOnBrowserUnload();
|
|
440
|
+
};
|
|
441
|
+
}*/
|
|
442
|
+
widgetStateEventName = getWidgetCacheId(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps13 = props.controlProps) === null || _props$controlProps13 === void 0 ? void 0 : _props$controlProps13.widgetInstanceId) ?? "");
|
|
365
443
|
const chatWidgetStateChangeEvent = {
|
|
366
444
|
eventName: widgetStateEventName,
|
|
367
445
|
payload: { ...state
|
|
@@ -374,7 +452,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
374
452
|
const setPostChatContextRelay = () => setPostChatContextAndLoadSurvey(chatSDK, dispatch); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
375
453
|
|
|
376
454
|
|
|
377
|
-
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat) => endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
455
|
+
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
378
456
|
|
|
379
457
|
|
|
380
458
|
const prepareEndChatRelay = (adapter, state) => prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
@@ -382,7 +460,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
382
460
|
const prepareStartChatRelay = () => prepareStartChat(props, chatSDK, state, dispatch, setAdapter); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
383
461
|
|
|
384
462
|
|
|
385
|
-
const initStartChatRelay = (optionalParams, persistedState) => initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
463
|
+
const initStartChatRelay = (optionalParams, persistedState) => initStartChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams, persistedState);
|
|
386
464
|
|
|
387
465
|
const confirmationPaneProps = initConfirmationPropsComposer(props);
|
|
388
466
|
return /*#__PURE__*/React.createElement(Composer, _extends({}, webChatProps, {
|
|
@@ -392,28 +470,28 @@ export const LiveChatWidgetStateful = props => {
|
|
|
392
470
|
id: widgetElementId,
|
|
393
471
|
styles: generalStyles,
|
|
394
472
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
395
|
-
}, !((_props$
|
|
473
|
+
}, !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideChatButton) && !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.skipChatButtonRendering) && shouldShowChatButton(state) && (decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/React.createElement(ChatButtonStateful, {
|
|
396
474
|
buttonProps: props.chatButtonProps,
|
|
397
475
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
398
476
|
startChat: prepareStartChatRelay
|
|
399
|
-
})), !((_props$
|
|
477
|
+
})), !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.hideProactiveChatPane) && shouldShowProactiveChatPane(state) && (decodeComponentString((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/React.createElement(ProactiveChatPaneStateful, {
|
|
400
478
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
401
479
|
startChat: prepareStartChatRelay
|
|
402
|
-
})), !((_props$
|
|
480
|
+
})), !((_props$controlProps17 = props.controlProps) !== null && _props$controlProps17 !== void 0 && _props$controlProps17.hideHeader) && shouldShowHeader(state) && (decodeComponentString((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/React.createElement(HeaderStateful, {
|
|
403
481
|
headerProps: props.headerProps,
|
|
404
482
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
405
483
|
endChat: endChatRelay
|
|
406
|
-
})), !((_props$
|
|
484
|
+
})), !((_props$controlProps18 = props.controlProps) !== null && _props$controlProps18 !== void 0 && _props$controlProps18.hideLoadingPane) && shouldShowLoadingPane(state) && (decodeComponentString((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/React.createElement(LoadingPaneStateful, props.loadingPaneProps)), !((_props$controlProps19 = props.controlProps) !== null && _props$controlProps19 !== void 0 && _props$controlProps19.hideOutOfOfficeHoursPane) && shouldShowOutOfOfficeHoursPane(state) && (decodeComponentString((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/React.createElement(OutOfOfficeHoursPaneStateful, props.outOfOfficeHoursPaneProps)), !((_props$controlProps20 = props.controlProps) !== null && _props$controlProps20 !== void 0 && _props$controlProps20.hideReconnectChatPane) && shouldShowReconnectChatPane(state) && (decodeComponentString((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/React.createElement(ReconnectChatPaneStateful, {
|
|
407
485
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
408
486
|
initStartChat: initStartChatRelay
|
|
409
|
-
})), !((_props$
|
|
487
|
+
})), !((_props$controlProps21 = props.controlProps) !== null && _props$controlProps21 !== void 0 && _props$controlProps21.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && (decodeComponentString((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
|
|
410
488
|
surveyProps: props.preChatSurveyPaneProps,
|
|
411
489
|
initStartChat: initStartChatRelay
|
|
412
|
-
})), !((_props$
|
|
490
|
+
})), !((_props$controlProps22 = props.controlProps) !== null && _props$controlProps22 !== void 0 && _props$controlProps22.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
|
|
413
491
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
414
|
-
}, props.callingContainerProps)), !((_props$
|
|
492
|
+
}, props.callingContainerProps)), !((_props$controlProps23 = props.controlProps) !== null && _props$controlProps23 !== void 0 && _props$controlProps23.hideWebChatContainer) && shouldShowWebChatContainer(state) && (decodeComponentString((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/React.createElement(WebChatContainerStateful, props.webChatContainerProps)), !((_props$controlProps24 = props.controlProps) !== null && _props$controlProps24 !== void 0 && _props$controlProps24.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
|
|
415
493
|
setPostChatContext: setPostChatContextRelay,
|
|
416
494
|
prepareEndChat: prepareEndChatRelay
|
|
417
|
-
}))), !((_props$
|
|
495
|
+
}))), !((_props$controlProps25 = props.controlProps) !== null && _props$controlProps25 !== void 0 && _props$controlProps25.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, props.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), createFooter(props, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, props.emailTranscriptPane))));
|
|
418
496
|
};
|
|
419
497
|
export default LiveChatWidgetStateful;
|
|
@@ -5,18 +5,19 @@ import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
|
|
|
5
5
|
import { defaultGeneralPostChatSurveyPaneStyleProps } from "./common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps";
|
|
6
6
|
import { findAllFocusableElement } from "../../common/utils";
|
|
7
7
|
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
8
|
+
import { PostChatSurveyMode } from "./enums/PostChatSurveyMode";
|
|
8
9
|
export const PostChatSurveyPaneStateful = props => {
|
|
9
|
-
var _props$styleProps, _props$controlProps;
|
|
10
|
-
|
|
11
|
-
const [state] = useChatContextStore(); // ToDo : TASK 2628392 Fix PostChat iframe reloading on Minimize
|
|
10
|
+
var _state$domainStates$l, _state$domainStates$l2, _props$styleProps, _props$controlProps;
|
|
12
11
|
|
|
12
|
+
const [state] = useChatContextStore();
|
|
13
|
+
const postChatSurveyMode = (_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_postconversationsurveymode;
|
|
13
14
|
const generalStyleProps = Object.assign({}, defaultGeneralPostChatSurveyPaneStyleProps, (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyleProps, {
|
|
14
15
|
display: state.appStates.isMinimized ? "none" : ""
|
|
15
16
|
});
|
|
16
17
|
let surveyInviteLink = "";
|
|
17
18
|
|
|
18
19
|
if (state.domainStates.postChatContext.surveyInviteLink) {
|
|
19
|
-
surveyInviteLink = state.domainStates.postChatContext.surveyInviteLink + "&lang=" + (state.domainStates.postChatContext.formsProLocale ?? "en");
|
|
20
|
+
surveyInviteLink = state.domainStates.postChatContext.surveyInviteLink + "&embed=" + (postChatSurveyMode === PostChatSurveyMode.Embed).toString() + "&compact=" + (props.isCustomerVoiceSurveyCompact ?? true).toString() + "&lang=" + (state.domainStates.postChatContext.formsProLocale ?? "en") + "&showmultilingual=false";
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
const styleProps = { ...props.styleProps,
|
package/lib/esm/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { HtmlAttributeNames, Regex } from "../../common/Constants";
|
|
2
2
|
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import React, { useEffect } from "react";
|
|
4
|
-
import { extractPreChatSurveyResponseValues, findAllFocusableElement,
|
|
4
|
+
import { extractPreChatSurveyResponseValues, findAllFocusableElement, getStateFromCache, isUndefinedOrEmpty, parseAdaptiveCardPayload } from "../../common/utils";
|
|
5
5
|
import { ConversationState } from "../../contexts/common/ConversationState";
|
|
6
|
-
import { DataStoreManager } from "../../common/contextDataStore/DataStoreManager";
|
|
7
6
|
import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
|
|
8
7
|
import { PreChatSurveyPane } from "@microsoft/omnichannel-chat-components";
|
|
9
8
|
import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
|
|
@@ -67,14 +66,12 @@ export const PreChatSurveyPaneStateful = props => {
|
|
|
67
66
|
});
|
|
68
67
|
|
|
69
68
|
try {
|
|
70
|
-
var _state$domainStates, _state$domainStates$t, _state$domainStates$t2,
|
|
69
|
+
var _state$domainStates, _state$domainStates$t, _state$domainStates$t2, _persistedState$domai, _persistedState$appSt;
|
|
71
70
|
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
75
|
-
let optionalParams = {};
|
|
71
|
+
const persistedState = getStateFromCache(((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$t = _state$domainStates.telemetryInternalData) === null || _state$domainStates$t === void 0 ? void 0 : _state$domainStates$t.orgId) ?? "", ((_state$domainStates$t2 = state.domainStates.telemetryInternalData) === null || _state$domainStates$t2 === void 0 ? void 0 : _state$domainStates$t2.widgetId) ?? "", state.domainStates.widgetInstanceId ?? "");
|
|
72
|
+
let optionalParams = {}; //Connect to Active chats and chat is not popout
|
|
76
73
|
|
|
77
|
-
if (persistedState
|
|
74
|
+
if (persistedState && !isUndefinedOrEmpty(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : _persistedState$domai.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt = persistedState.appStates) === null || _persistedState$appSt === void 0 ? void 0 : _persistedState$appSt.conversationState) === ConversationState.Active && !state.appStates.skipChatButtonRendering) {
|
|
78
75
|
var _persistedState$domai2;
|
|
79
76
|
|
|
80
77
|
optionalParams = {
|