@microsoft/omnichannel-chat-widget 1.0.3-main.05297ce → 1.0.3-main.1acfc60
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 +54 -1
- package/lib/cjs/common/storage/default/defaultCacheManager.js +7 -6
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +9 -7
- package/lib/cjs/common/telemetry/TelemetryConstants.js +7 -1
- package/lib/cjs/common/utils.js +27 -5
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +1 -10
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -6
- package/lib/cjs/components/footerstateful/FooterStateful.js +1 -1
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +14 -13
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +2 -3
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +11 -3
- package/lib/cjs/components/livechatwidget/common/endChat.js +197 -99
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +41 -21
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -8
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +139 -0
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +2 -255
- package/lib/cjs/components/livechatwidget/common/startChat.js +85 -69
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +162 -100
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +2 -2
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +18 -8
- package/lib/cjs/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -2
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -4
- package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +62 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +8 -6
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +7 -1
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +16 -13
- package/lib/cjs/contexts/createReducer.js +13 -23
- package/lib/cjs/controller/componentController.js +2 -1
- package/lib/cjs/index.js +20 -0
- package/lib/esm/common/Constants.js +49 -0
- package/lib/esm/common/storage/default/defaultCacheManager.js +5 -4
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +9 -7
- package/lib/esm/common/telemetry/TelemetryConstants.js +7 -1
- package/lib/esm/common/utils.js +25 -4
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -13
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -6
- package/lib/esm/components/footerstateful/FooterStateful.js +1 -1
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -1
- package/lib/esm/components/headerstateful/HeaderStateful.js +14 -13
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +2 -3
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +11 -3
- package/lib/esm/components/livechatwidget/common/endChat.js +196 -99
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +41 -21
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +11 -8
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +130 -0
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -255
- package/lib/esm/components/livechatwidget/common/startChat.js +86 -70
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +164 -102
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +2 -2
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +18 -8
- package/lib/esm/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -2
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -4
- package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +54 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +8 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +7 -1
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +18 -15
- package/lib/esm/contexts/createReducer.js +13 -23
- package/lib/esm/controller/componentController.js +2 -1
- package/lib/esm/index.js +4 -1
- package/lib/types/common/Constants.d.ts +21 -0
- package/lib/types/common/interfaces/IContextDataStore.d.ts +3 -3
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +2 -1
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +7 -1
- package/lib/types/common/utils.d.ts +3 -2
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +6 -0
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
- package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -6
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +3 -1
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.d.ts +9 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +8 -7
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +2 -1
- package/lib/types/index.d.ts +3 -0
- package/package.json +2 -1
- package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +0 -36
- package/lib/cjs/contexts/common/ConversationEndEntity.js +0 -12
- package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +0 -30
- package/lib/esm/contexts/common/ConversationEndEntity.js +0 -5
- package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +0 -6
- package/lib/types/contexts/common/ConversationEndEntity.d.ts +0 -4
|
@@ -6,22 +6,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = exports.LiveChatWidgetStateful = void 0;
|
|
7
7
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
8
8
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
9
|
-
var _Constants = require("../../../common/Constants");
|
|
10
9
|
var _react = require("@fluentui/react");
|
|
11
10
|
var _react2 = _interopRequireWildcard(require("react"));
|
|
12
11
|
var _startChat = require("../common/startChat");
|
|
13
12
|
var _utils = require("../../../common/utils");
|
|
14
13
|
var _endChat = require("../common/endChat");
|
|
15
|
-
var _reconnectChatHelper = require("../common/reconnectChatHelper");
|
|
16
14
|
var _componentController = require("../../../controller/componentController");
|
|
17
15
|
var _ActivityStreamHandler = require("../common/ActivityStreamHandler");
|
|
18
16
|
var _CallingContainerStateful = _interopRequireDefault(require("../../callingcontainerstateful/CallingContainerStateful"));
|
|
19
17
|
var _ChatButtonStateful = _interopRequireDefault(require("../../chatbuttonstateful/ChatButtonStateful"));
|
|
20
18
|
var _botframeworkWebchat = require("botframework-webchat");
|
|
21
19
|
var _ConfirmationPaneStateful = _interopRequireDefault(require("../../confirmationpanestateful/ConfirmationPaneStateful"));
|
|
22
|
-
var _ConversationEndEntity = require("../../../contexts/common/ConversationEndEntity");
|
|
23
20
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
24
21
|
var _DataStoreManager = require("../../../common/contextDataStore/DataStoreManager");
|
|
22
|
+
var _Constants = require("../../../common/Constants");
|
|
25
23
|
var _EmailTranscriptPaneStateful = _interopRequireDefault(require("../../emailtranscriptpanestateful/EmailTranscriptPaneStateful"));
|
|
26
24
|
var _HeaderStateful = _interopRequireDefault(require("../../headerstateful/HeaderStateful"));
|
|
27
25
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
@@ -42,7 +40,6 @@ var _defaultScrollBarProps = require("../common/defaultProps/defaultScrollBarPro
|
|
|
42
40
|
var _defaultWebChatContainerStatefulProps = require("../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps");
|
|
43
41
|
var _disposeTelemetryLoggers = require("../common/disposeTelemetryLoggers");
|
|
44
42
|
var _getGeneralStylesForButton = require("../common/getGeneralStylesForButton");
|
|
45
|
-
var _agentEndConversationHelper = require("../common/agentEndConversationHelper");
|
|
46
43
|
var _chatDisconnectHelper = require("../common/chatDisconnectHelper");
|
|
47
44
|
var _initCallingSdk = require("../common/initCallingSdk");
|
|
48
45
|
var _initConfirmationPropsComposer = require("../common/initConfirmationPropsComposer");
|
|
@@ -54,12 +51,13 @@ var _startProactiveChat = require("../common/startProactiveChat");
|
|
|
54
51
|
var _useChatAdapterStore = _interopRequireDefault(require("../../../hooks/useChatAdapterStore"));
|
|
55
52
|
var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useChatContextStore"));
|
|
56
53
|
var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDKStore"));
|
|
54
|
+
var _reconnectChatHelper = require("../common/reconnectChatHelper");
|
|
57
55
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
58
56
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
59
57
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
60
58
|
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); }
|
|
61
59
|
const LiveChatWidgetStateful = props => {
|
|
62
|
-
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$
|
|
60
|
+
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _state$appStates7, _props$webChatContain5, _state$appStates10, _state$appStates15, _props$webChatContain6, _props$styleProps2, _props$controlProps11, _props$controlProps12, _props$componentOverr, _props$controlProps13, _props$componentOverr2, _props$controlProps14, _props$componentOverr3, _props$controlProps15, _props$componentOverr4, _props$controlProps16, _props$componentOverr5, _props$controlProps17, _props$componentOverr6, _props$controlProps18, _props$componentOverr7, _props$controlProps19, _props$controlProps20, _props$componentOverr8, _props$controlProps21, _props$componentOverr9, _props$controlProps22, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
63
61
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
64
62
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
63
|
const [adapter, setAdapter] = (0, _useChatAdapterStore.default)();
|
|
@@ -88,23 +86,25 @@ const LiveChatWidgetStateful = props => {
|
|
|
88
86
|
_TelemetryManager.TelemetryTimers.LcwLoadToChatButtonTimer = (0, _utils.createTimer)();
|
|
89
87
|
const widgetElementId = ((_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.id) || "oc-lcw";
|
|
90
88
|
const currentMessageCountRef = (0, _react2.useRef)(0);
|
|
89
|
+
let widgetStateEventId = "";
|
|
91
90
|
const lastLWICheckTimeRef = (0, _react2.useRef)(0);
|
|
92
|
-
let widgetStateEventName = "";
|
|
93
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
91
|
let optionalParams;
|
|
95
92
|
let activeCachedChatExist = false;
|
|
93
|
+
const uwid = (0, _react2.useRef)(""); // its an uniqueid per chatr instance
|
|
94
|
+
|
|
96
95
|
const setOptionalParams = () => {
|
|
97
|
-
var _state$appStates, _state$domainStates;
|
|
96
|
+
var _state$appStates, _state$domainStates, _state$appStates3;
|
|
98
97
|
if (!(0, _utils.isUndefinedOrEmpty)((_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.reconnectId)) {
|
|
98
|
+
var _state$appStates2;
|
|
99
99
|
activeCachedChatExist = true;
|
|
100
100
|
optionalParams = {
|
|
101
|
-
reconnectId: state.appStates.reconnectId
|
|
101
|
+
reconnectId: state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.reconnectId
|
|
102
102
|
};
|
|
103
|
-
} else if (!(0, _utils.isUndefinedOrEmpty)((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext)) {
|
|
103
|
+
} else if (!(0, _utils.isUndefinedOrEmpty)(state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext) && (state === null || state === void 0 ? void 0 : (_state$appStates3 = state.appStates) === null || _state$appStates3 === void 0 ? void 0 : _state$appStates3.conversationState) === _ConversationState.ConversationState.Active) {
|
|
104
104
|
var _state$domainStates2;
|
|
105
105
|
activeCachedChatExist = true;
|
|
106
106
|
optionalParams = {
|
|
107
|
-
liveChatContext: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
|
|
107
|
+
liveChatContext: state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
|
|
108
108
|
};
|
|
109
109
|
} else {
|
|
110
110
|
activeCachedChatExist = false;
|
|
@@ -115,7 +115,6 @@ const LiveChatWidgetStateful = props => {
|
|
|
115
115
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
116
116
|
const startChat = async (props, localState) => {
|
|
117
117
|
let isChatValid = false;
|
|
118
|
-
|
|
119
118
|
//Start a chat from cache/reconnectid
|
|
120
119
|
if (activeCachedChatExist === true) {
|
|
121
120
|
dispatch({
|
|
@@ -146,9 +145,18 @@ const LiveChatWidgetStateful = props => {
|
|
|
146
145
|
await (0, _startChat.setPreChatAndInitiateChat)(chatSDK, dispatch, setAdapter, undefined, undefined, localState, props);
|
|
147
146
|
return;
|
|
148
147
|
} else {
|
|
148
|
+
var _state$appStates4;
|
|
149
|
+
// To avoid showing blank screen in popout
|
|
150
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates4 = state.appStates) === null || _state$appStates4 === void 0 ? void 0 : _state$appStates4.hideStartChatButton) === false) {
|
|
151
|
+
dispatch({
|
|
152
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
153
|
+
payload: _ConversationState.ConversationState.Closed
|
|
154
|
+
});
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
149
157
|
dispatch({
|
|
150
158
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
151
|
-
payload: _ConversationState.ConversationState.
|
|
159
|
+
payload: _ConversationState.ConversationState.Loading
|
|
152
160
|
});
|
|
153
161
|
}
|
|
154
162
|
}
|
|
@@ -157,37 +165,42 @@ const LiveChatWidgetStateful = props => {
|
|
|
157
165
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
158
166
|
const setupClientDataStore = () => {
|
|
159
167
|
// Add default localStorage support for widget
|
|
168
|
+
const widgetCacheId = (0, _utils.getWidgetCacheIdfromProps)(props);
|
|
160
169
|
if (props.contextDataStore === undefined) {
|
|
161
|
-
var _props$controlProps3
|
|
170
|
+
var _props$controlProps3;
|
|
162
171
|
const cacheTtlInMins = (props === null || props === void 0 ? void 0 : (_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.cacheTtlInMins) ?? _Constants.Constants.CacheTtlInMinutes;
|
|
163
|
-
|
|
164
|
-
|
|
172
|
+
const storageType = (props === null || props === void 0 ? void 0 : props.useSessionStorage) === true ? _Constants.StorageType.sessionStorage : _Constants.StorageType.localStorage;
|
|
173
|
+
_DataStoreManager.DataStoreManager.clientDataStore = (0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)(cacheTtlInMins, storageType);
|
|
174
|
+
(0, _defaultCacheManager.registerBroadcastServiceForStorage)(widgetCacheId, cacheTtlInMins, storageType);
|
|
165
175
|
} else {
|
|
166
176
|
_DataStoreManager.DataStoreManager.clientDataStore = props.contextDataStore;
|
|
167
177
|
}
|
|
168
178
|
};
|
|
169
179
|
(0, _react2.useEffect)(() => {
|
|
170
|
-
var _props$
|
|
180
|
+
var _props$controlProps4, _props$controlProps5, _props$controlProps6, _props$chatConfig, _props$chatConfig$Liv, _props$controlProps8, _props$chatConfig2, _props$chatConfig2$Ch, _state$appStates5;
|
|
181
|
+
state.domainStates.confirmationPaneConfirmedOptionClicked = false;
|
|
182
|
+
state.domainStates.confirmationState = _Constants.ConfirmationState.NotSet;
|
|
171
183
|
setupClientDataStore();
|
|
172
184
|
(0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
|
|
173
185
|
(0, _createInternetConnectionChangeHandler.createInternetConnectionChangeHandler)();
|
|
186
|
+
uwid.current = (0, _utils.newGuid)();
|
|
174
187
|
dispatch({
|
|
175
188
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_ELEMENT_ID,
|
|
176
189
|
payload: widgetElementId
|
|
177
190
|
});
|
|
178
191
|
dispatch({
|
|
179
192
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_BUTTON_DISPLAY,
|
|
180
|
-
payload: ((_props$
|
|
193
|
+
payload: ((_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.hideStartChatButton) || false
|
|
181
194
|
});
|
|
182
195
|
dispatch({
|
|
183
196
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
184
197
|
payload: false
|
|
185
198
|
});
|
|
186
|
-
if ((_props$
|
|
187
|
-
var _props$
|
|
199
|
+
if ((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.widgetInstanceId && !(0, _utils.isNullOrEmptyString)((_props$controlProps6 = props.controlProps) === null || _props$controlProps6 === void 0 ? void 0 : _props$controlProps6.widgetInstanceId)) {
|
|
200
|
+
var _props$controlProps7;
|
|
188
201
|
dispatch({
|
|
189
202
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID,
|
|
190
|
-
payload: (_props$
|
|
203
|
+
payload: (_props$controlProps7 = props.controlProps) === null || _props$controlProps7 === void 0 ? void 0 : _props$controlProps7.widgetInstanceId
|
|
191
204
|
});
|
|
192
205
|
}
|
|
193
206
|
if (((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.msdyn_callingoptions) !== _Constants.E2VVOptions.NoCalling) {
|
|
@@ -206,7 +219,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
206
219
|
}
|
|
207
220
|
|
|
208
221
|
// Initialize global dir
|
|
209
|
-
const globalDir = ((_props$
|
|
222
|
+
const globalDir = ((_props$controlProps8 = props.controlProps) === null || _props$controlProps8 === void 0 ? void 0 : _props$controlProps8.dir) ?? (0, _utils.getLocaleDirection)((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Ch = _props$chatConfig2.ChatWidgetLanguage) === null || _props$chatConfig2$Ch === void 0 ? void 0 : _props$chatConfig2$Ch.msdyn_localeid);
|
|
210
223
|
dispatch({
|
|
211
224
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_GLOBAL_DIR,
|
|
212
225
|
payload: globalDir
|
|
@@ -214,25 +227,35 @@ const LiveChatWidgetStateful = props => {
|
|
|
214
227
|
setOptionalParams();
|
|
215
228
|
|
|
216
229
|
// Unauth chat
|
|
217
|
-
if (state.appStates.hideStartChatButton === false) {
|
|
230
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates5 = state.appStates) === null || _state$appStates5 === void 0 ? void 0 : _state$appStates5.hideStartChatButton) === false) {
|
|
218
231
|
startChat(props);
|
|
219
232
|
}
|
|
220
233
|
}, []);
|
|
221
234
|
|
|
222
235
|
// useEffect for when skip chat button rendering
|
|
223
236
|
(0, _react2.useEffect)(() => {
|
|
224
|
-
|
|
237
|
+
var _state$appStates6;
|
|
238
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates6 = state.appStates) === null || _state$appStates6 === void 0 ? void 0 : _state$appStates6.hideStartChatButton) === true) {
|
|
239
|
+
var _props$chatConfig3, _props$chatConfig3$Li;
|
|
240
|
+
//handle OOH pane
|
|
241
|
+
if ((props === null || props === void 0 ? void 0 : (_props$chatConfig3 = props.chatConfig) === null || _props$chatConfig3 === void 0 ? void 0 : (_props$chatConfig3$Li = _props$chatConfig3.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig3$Li === void 0 ? void 0 : _props$chatConfig3$Li.OutOfOperatingHours.toLowerCase()) === "true") {
|
|
242
|
+
dispatch({
|
|
243
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
244
|
+
payload: _ConversationState.ConversationState.OutOfOffice
|
|
245
|
+
});
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
225
248
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
226
249
|
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
227
250
|
});
|
|
228
251
|
//Pass the state to avoid getting stale state
|
|
229
252
|
startChat(props, state);
|
|
230
253
|
}
|
|
231
|
-
}, [state.appStates.hideStartChatButton]);
|
|
254
|
+
}, [state === null || state === void 0 ? void 0 : (_state$appStates7 = state.appStates) === null || _state$appStates7 === void 0 ? void 0 : _state$appStates7.hideStartChatButton]);
|
|
232
255
|
|
|
233
256
|
// useEffect for custom context
|
|
234
257
|
(0, _react2.useEffect)(() => {
|
|
235
|
-
var _chatSDK$
|
|
258
|
+
var _chatSDK$omnichannelC2, _chatSDK$omnichannelC3, _props$controlProps10;
|
|
236
259
|
// Add the custom context on receiving the SetCustomContext event
|
|
237
260
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
238
261
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -261,11 +284,12 @@ const LiveChatWidgetStateful = props => {
|
|
|
261
284
|
});
|
|
262
285
|
|
|
263
286
|
// Toggle chat visibility
|
|
287
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
264
288
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.HideChatVisibilityChangeEvent).subscribe(async event => {
|
|
265
289
|
var _event$payload;
|
|
266
290
|
if ((event === null || event === void 0 ? void 0 : (_event$payload = event.payload) === null || _event$payload === void 0 ? void 0 : _event$payload.isChatHidden) !== undefined) {
|
|
267
|
-
var _props$
|
|
268
|
-
if ((_props$
|
|
291
|
+
var _props$controlProps9;
|
|
292
|
+
if ((_props$controlProps9 = props.controlProps) !== null && _props$controlProps9 !== void 0 && _props$controlProps9.hideStartChatButton) {
|
|
269
293
|
var _event$payload2;
|
|
270
294
|
dispatch({
|
|
271
295
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
@@ -292,14 +316,15 @@ const LiveChatWidgetStateful = props => {
|
|
|
292
316
|
|
|
293
317
|
// Start chat from SDK Event
|
|
294
318
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(() => {
|
|
295
|
-
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$controlProps11;
|
|
296
319
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
297
320
|
Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
|
|
298
321
|
Description: "Start chat event received."
|
|
299
322
|
});
|
|
300
|
-
const persistedState = (0, _utils.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$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
301
323
|
|
|
302
|
-
//
|
|
324
|
+
// DataStoreManager.clientDataStore?.swtichToSessionStorage(true);
|
|
325
|
+
const persistedState = (0, _utils.getStateFromCache)((0, _utils.getWidgetCacheIdfromProps)(props));
|
|
326
|
+
|
|
327
|
+
// Chat not found in cache - scenario: explicitly clearing cache and calling startChat SDK method
|
|
303
328
|
if (persistedState === undefined) {
|
|
304
329
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
305
330
|
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
@@ -310,9 +335,9 @@ const LiveChatWidgetStateful = props => {
|
|
|
310
335
|
|
|
311
336
|
// Chat exist in cache
|
|
312
337
|
if (persistedState) {
|
|
313
|
-
var _persistedState$
|
|
338
|
+
var _persistedState$appSt, _persistedState$appSt2, _persistedState$appSt3, _persistedState$appSt4;
|
|
314
339
|
// Only initiate new chat if widget state in cache in one of the followings
|
|
315
|
-
if (persistedState.appStates.conversationState === _ConversationState.ConversationState.Closed || persistedState.appStates.conversationState === _ConversationState.ConversationState.InActive || persistedState.appStates.conversationState === _ConversationState.ConversationState.Postchat) {
|
|
340
|
+
if (((_persistedState$appSt = persistedState.appStates) === null || _persistedState$appSt === void 0 ? void 0 : _persistedState$appSt.conversationState) === _ConversationState.ConversationState.Closed || ((_persistedState$appSt2 = persistedState.appStates) === null || _persistedState$appSt2 === void 0 ? void 0 : _persistedState$appSt2.conversationState) === _ConversationState.ConversationState.InActive || ((_persistedState$appSt3 = persistedState.appStates) === null || _persistedState$appSt3 === void 0 ? void 0 : _persistedState$appSt3.conversationState) === _ConversationState.ConversationState.Postchat) {
|
|
316
341
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
317
342
|
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
318
343
|
});
|
|
@@ -321,33 +346,33 @@ const LiveChatWidgetStateful = props => {
|
|
|
321
346
|
}
|
|
322
347
|
|
|
323
348
|
// If minimized, maximize the chat
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
349
|
+
if ((persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt4 = persistedState.appStates) === null || _persistedState$appSt4 === void 0 ? void 0 : _persistedState$appSt4.isMinimized) === true) {
|
|
350
|
+
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4;
|
|
351
|
+
dispatch({
|
|
352
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
353
|
+
payload: false
|
|
354
|
+
});
|
|
355
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
356
|
+
eventName: _TelemetryConstants.BroadcastEvent.MaximizeChat,
|
|
357
|
+
payload: {
|
|
358
|
+
height: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : (_persistedState$domai2 = _persistedState$domai.widgetSize) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.height,
|
|
359
|
+
width: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai3 = persistedState.domainStates) === null || _persistedState$domai3 === void 0 ? void 0 : (_persistedState$domai4 = _persistedState$domai3.widgetSize) === null || _persistedState$domai4 === void 0 ? void 0 : _persistedState$domai4.width
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
335
363
|
}
|
|
336
364
|
});
|
|
337
365
|
|
|
338
366
|
// End chat
|
|
339
367
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
const skipCloseChat = false;
|
|
349
|
-
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
|
|
350
|
-
}
|
|
368
|
+
// This is to ensure to get latest state from cache in multitab
|
|
369
|
+
const persistedState = (0, _utils.getStateFromCache)((0, _utils.getWidgetCacheIdfromProps)(props));
|
|
370
|
+
if (persistedState && persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
371
|
+
(0, _endChat.prepareEndChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid.current);
|
|
372
|
+
} else {
|
|
373
|
+
const skipEndChatSDK = true;
|
|
374
|
+
const skipCloseChat = false;
|
|
375
|
+
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat);
|
|
351
376
|
}
|
|
352
377
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
353
378
|
eventName: _TelemetryConstants.BroadcastEvent.CloseChat
|
|
@@ -360,17 +385,15 @@ const LiveChatWidgetStateful = props => {
|
|
|
360
385
|
});
|
|
361
386
|
|
|
362
387
|
// Listen to end chat event from other tabs
|
|
363
|
-
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$
|
|
364
|
-
_omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(
|
|
365
|
-
|
|
366
|
-
|
|
388
|
+
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(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$controlProps10 = props.controlProps) === null || _props$controlProps10 === void 0 ? void 0 : _props$controlProps10.widgetInstanceId) ?? "");
|
|
389
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(msg => {
|
|
390
|
+
console.log("Receiving end chat event", JSON.stringify(msg.payload));
|
|
391
|
+
if (msg.payload !== uwid.current) {
|
|
392
|
+
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, false);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
367
395
|
});
|
|
368
396
|
|
|
369
|
-
// When conversation ended by agent
|
|
370
|
-
if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Agent) {
|
|
371
|
-
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
397
|
//Listen to WidgetSize, used for minimize to maximize
|
|
375
398
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName("WidgetSize").subscribe(msg => {
|
|
376
399
|
dispatch({
|
|
@@ -419,6 +442,17 @@ const LiveChatWidgetStateful = props => {
|
|
|
419
442
|
});
|
|
420
443
|
});
|
|
421
444
|
}
|
|
445
|
+
if (state.appStates.conversationState === _ConversationState.ConversationState.InActive) {
|
|
446
|
+
var _props$webChatContain2, _props$webChatContain3;
|
|
447
|
+
if ((props === null || props === void 0 ? void 0 : (_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : (_props$webChatContain3 = _props$webChatContain2.renderingMiddlewareProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.hideSendboxOnConversationEnd) !== false) {
|
|
448
|
+
setWebChatStyles(styles => {
|
|
449
|
+
return {
|
|
450
|
+
...styles,
|
|
451
|
+
hideSendBox: true
|
|
452
|
+
};
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
}
|
|
422
456
|
}, [state.appStates.conversationState]);
|
|
423
457
|
(0, _react2.useEffect)(() => {
|
|
424
458
|
canStartProactiveChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Closed && !state.appStates.proactiveChatStates.proactiveChatInNewWindow;
|
|
@@ -456,16 +490,55 @@ const LiveChatWidgetStateful = props => {
|
|
|
456
490
|
}
|
|
457
491
|
}, [state.appStates.unreadMessageCount]);
|
|
458
492
|
(0, _react2.useEffect)(() => {
|
|
459
|
-
var _props$
|
|
493
|
+
var _props$webChatContain4;
|
|
460
494
|
setWebChatStyles({
|
|
461
495
|
...webChatStyles,
|
|
462
|
-
...((_props$
|
|
496
|
+
...((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.webChatStyles)
|
|
463
497
|
});
|
|
464
|
-
}, [(_props$
|
|
498
|
+
}, [(_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.webChatStyles]);
|
|
499
|
+
(0, _react2.useEffect)(() => {
|
|
500
|
+
//Confirmation pane dismissing through OK option, so proceed with end chat
|
|
501
|
+
if (state.domainStates.confirmationState === _Constants.ConfirmationState.Ok) {
|
|
502
|
+
dispatch({
|
|
503
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
|
|
504
|
+
payload: _Constants.ConversationEndEntity.Customer
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
}, [state.domainStates.confirmationState]);
|
|
508
|
+
(0, _react2.useEffect)(() => {
|
|
509
|
+
var _state$appStates8, _state$appStates9;
|
|
510
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates8 = state.appStates) === null || _state$appStates8 === void 0 ? void 0 : _state$appStates8.conversationEndedBy) === _Constants.ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates9 = state.appStates) === null || _state$appStates9 === void 0 ? void 0 : _state$appStates9.conversationEndedBy) === _Constants.ConversationEndEntity.Bot) {
|
|
511
|
+
dispatch({
|
|
512
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
513
|
+
payload: _ConversationState.ConversationState.InActive
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
}, [state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationEndedBy]);
|
|
517
|
+
(0, _react2.useEffect)(() => {
|
|
518
|
+
var _state$appStates11, _state$appStates12, _state$appStates13, _state$appStates14;
|
|
519
|
+
// Do not process anything during initialization
|
|
520
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationEndedBy) === _Constants.ConversationEndEntity.NotSet) {
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// If start chat failed, and C2 is trying to close chat widget
|
|
525
|
+
if (state !== null && state !== void 0 && (_state$appStates12 = state.appStates) !== null && _state$appStates12 !== void 0 && _state$appStates12.startChatFailed) {
|
|
526
|
+
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// Scenario -> Chat was InActive and closing the chat (Refresh scenario on post chat)
|
|
531
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationState) === _ConversationState.ConversationState.Postchat || (state === null || state === void 0 ? void 0 : (_state$appStates14 = state.appStates) === null || _state$appStates14 === void 0 ? void 0 : _state$appStates14.conversationState) === _ConversationState.ConversationState.InActive) {
|
|
532
|
+
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
//All other cases
|
|
537
|
+
(0, _endChat.prepareEndChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid.current);
|
|
538
|
+
}, [state === null || state === void 0 ? void 0 : (_state$appStates15 = state.appStates) === null || _state$appStates15 === void 0 ? void 0 : _state$appStates15.conversationEndedBy]);
|
|
465
539
|
|
|
466
540
|
// Publish chat widget state
|
|
467
541
|
(0, _react2.useEffect)(() => {
|
|
468
|
-
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps14;
|
|
469
542
|
// Only activate these windows events when conversation state is active and chat widget is in popout mode
|
|
470
543
|
// Ghost chat scenarios
|
|
471
544
|
/* COMMENTING THIS CODE FOR PARITY WITH OLD LCW
|
|
@@ -477,15 +550,15 @@ const LiveChatWidgetStateful = props => {
|
|
|
477
550
|
const prompt = Constants.BrowserUnloadConfirmationMessage;
|
|
478
551
|
return prompt;
|
|
479
552
|
};
|
|
480
|
-
|
|
553
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
481
554
|
window.onunload = function () {
|
|
482
555
|
initiateEndChatOnBrowserUnload();
|
|
483
556
|
};
|
|
484
557
|
}*/
|
|
485
558
|
|
|
486
|
-
|
|
559
|
+
widgetStateEventId = (0, _utils.getWidgetCacheIdfromProps)(props);
|
|
487
560
|
const chatWidgetStateChangeEvent = {
|
|
488
|
-
eventName:
|
|
561
|
+
eventName: widgetStateEventId,
|
|
489
562
|
payload: {
|
|
490
563
|
...state
|
|
491
564
|
}
|
|
@@ -493,20 +566,6 @@ const LiveChatWidgetStateful = props => {
|
|
|
493
566
|
_omnichannelChatComponents.BroadcastService.postMessage(chatWidgetStateChangeEvent);
|
|
494
567
|
}, [state]);
|
|
495
568
|
|
|
496
|
-
// Initiate End chat from a single point
|
|
497
|
-
(0, _react2.useEffect)(() => {
|
|
498
|
-
if (state.appStates.conversationEndedBy !== undefined) {
|
|
499
|
-
(0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
500
|
-
}
|
|
501
|
-
}, [state.appStates.conversationEndedBy]);
|
|
502
|
-
|
|
503
|
-
// Handle Agent end conversation cases
|
|
504
|
-
(0, _react2.useEffect)(() => {
|
|
505
|
-
if (state.appStates.conversationEndedByAgentEventReceived) {
|
|
506
|
-
(0, _agentEndConversationHelper.handleAgentEndConversation)(props, state, dispatch);
|
|
507
|
-
}
|
|
508
|
-
}, [state.appStates.conversationEndedByAgentEventReceived]);
|
|
509
|
-
|
|
510
569
|
// Handle Chat disconnect cases
|
|
511
570
|
(0, _react2.useEffect)(() => {
|
|
512
571
|
if (state.appStates.chatDisconnectEventReceived) {
|
|
@@ -519,9 +578,9 @@ const LiveChatWidgetStateful = props => {
|
|
|
519
578
|
Event: _TelemetryConstants.TelemetryEvent.BrowserUnloadEventStarted,
|
|
520
579
|
Description: "Browser unload event received."
|
|
521
580
|
});
|
|
522
|
-
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles,
|
|
581
|
+
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, false);
|
|
523
582
|
// Clean local storage
|
|
524
|
-
(_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(
|
|
583
|
+
(_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventId);
|
|
525
584
|
|
|
526
585
|
//Dispose calling instance
|
|
527
586
|
if (voiceVideoCallingSDK) {
|
|
@@ -532,14 +591,16 @@ const LiveChatWidgetStateful = props => {
|
|
|
532
591
|
eventName: _TelemetryConstants.BroadcastEvent.ClosePopoutWindow
|
|
533
592
|
});
|
|
534
593
|
};
|
|
535
|
-
const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props,
|
|
594
|
+
const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, state, dispatch, chatSDK);
|
|
536
595
|
const setPostChatContextRelay = () => (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
|
|
537
596
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
538
|
-
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles,
|
|
597
|
+
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab, uwid.current);
|
|
539
598
|
const prepareStartChatRelay = () => (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
540
599
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
541
600
|
const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
|
|
542
601
|
const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
|
|
602
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
603
|
+
const prepareEndChatRelay = () => (0, _endChat.prepareEndChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid.current);
|
|
543
604
|
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement("style", null, `
|
|
544
605
|
::-webkit-scrollbar {
|
|
545
606
|
width: ${scrollbarProps.width};
|
|
@@ -559,36 +620,37 @@ const LiveChatWidgetStateful = props => {
|
|
|
559
620
|
}
|
|
560
621
|
`), /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
|
|
561
622
|
styleOptions: webChatStyles,
|
|
562
|
-
directLine: ((_props$
|
|
623
|
+
directLine: ((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.directLine) ?? adapter ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.directLine
|
|
563
624
|
}), /*#__PURE__*/_react2.default.createElement(_react.Stack, {
|
|
564
625
|
id: widgetElementId,
|
|
565
626
|
styles: generalStyles,
|
|
566
627
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
567
|
-
}, !((_props$
|
|
628
|
+
}, !((_props$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.hideChatButton) && !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.hideStartChatButton) && (0, _componentController.shouldShowChatButton)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/_react2.default.createElement(_ChatButtonStateful.default, {
|
|
568
629
|
buttonProps: props.chatButtonProps,
|
|
569
630
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
570
631
|
startChat: prepareStartChatRelay
|
|
571
|
-
})), !((_props$
|
|
632
|
+
})), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideProactiveChatPane) && (0, _componentController.shouldShowProactiveChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/_react2.default.createElement(_ProactiveChatPaneStateful.default, {
|
|
572
633
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
573
634
|
startChat: prepareStartChatRelay
|
|
574
|
-
})), !((_props$
|
|
635
|
+
})), !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideHeader) && (0, _componentController.shouldShowHeader)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/_react2.default.createElement(_HeaderStateful.default, {
|
|
575
636
|
headerProps: props.headerProps,
|
|
576
637
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
577
638
|
endChat: endChatRelay
|
|
578
|
-
})), !((_props$
|
|
639
|
+
})), !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hideLoadingPane) && (0, _componentController.shouldShowLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/_react2.default.createElement(_LoadingPaneStateful.default, {
|
|
579
640
|
loadingPaneProps: props.loadingPaneProps,
|
|
580
641
|
startChatErrorPaneProps: props.startChatErrorPaneProps
|
|
581
|
-
})), !((_props$
|
|
642
|
+
})), !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.hideOutOfOfficeHoursPane) && (0, _componentController.shouldShowOutOfOfficeHoursPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/_react2.default.createElement(_OOOHPaneStateful.default, props.outOfOfficeHoursPaneProps)), !((_props$controlProps17 = props.controlProps) !== null && _props$controlProps17 !== void 0 && _props$controlProps17.hideReconnectChatPane) && (0, _componentController.shouldShowReconnectChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/_react2.default.createElement(_ReconnectChatPaneStateful.default, {
|
|
582
643
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
583
644
|
initStartChat: initStartChatRelay
|
|
584
|
-
})), !((_props$
|
|
645
|
+
})), !((_props$controlProps18 = props.controlProps) !== null && _props$controlProps18 !== void 0 && _props$controlProps18.hidePreChatSurveyPane) && (0, _componentController.shouldShowPreChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PreChatSurveyPaneStateful.default, {
|
|
585
646
|
surveyProps: props.preChatSurveyPaneProps,
|
|
586
647
|
initStartChat: initStartChatRelay
|
|
587
|
-
})), !((_props$
|
|
648
|
+
})), !((_props$controlProps19 = props.controlProps) !== null && _props$controlProps19 !== void 0 && _props$controlProps19.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
|
|
588
649
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
589
|
-
}, props.callingContainerProps)), !((_props$
|
|
590
|
-
setPostChatContext: setPostChatContextRelay
|
|
591
|
-
|
|
650
|
+
}, props.callingContainerProps)), !((_props$controlProps20 = props.controlProps) !== null && _props$controlProps20 !== void 0 && _props$controlProps20.hideWebChatContainer) && (0, _componentController.shouldShowWebChatContainer)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/_react2.default.createElement(_WebChatContainerStateful.default, props.webChatContainerProps)), !((_props$controlProps21 = props.controlProps) !== null && _props$controlProps21 !== void 0 && _props$controlProps21.hideConfirmationPane) && (0, _componentController.shouldShowConfirmationPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/_react2.default.createElement(_ConfirmationPaneStateful.default, _extends({}, confirmationPaneProps, {
|
|
651
|
+
setPostChatContext: setPostChatContextRelay,
|
|
652
|
+
prepareEndChat: prepareEndChatRelay
|
|
653
|
+
}))), !((_props$controlProps22 = props.controlProps) !== null && _props$controlProps22 !== void 0 && _props$controlProps22.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, props.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), (0, _createFooter.createFooter)(props, state), (0, _componentController.shouldShowEmailTranscriptPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/_react2.default.createElement(_EmailTranscriptPaneStateful.default, props.emailTranscriptPane)))));
|
|
592
654
|
};
|
|
593
655
|
exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
|
|
594
656
|
var _default = LiveChatWidgetStateful;
|
|
@@ -64,8 +64,8 @@ const LoadingPaneStateful = props => {
|
|
|
64
64
|
}, []);
|
|
65
65
|
return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.LoadingPane, {
|
|
66
66
|
componentOverrides: loadingPaneProps === null || loadingPaneProps === void 0 ? void 0 : loadingPaneProps.componentOverrides,
|
|
67
|
-
controlProps: state.appStates.
|
|
68
|
-
styleProps: state.appStates.
|
|
67
|
+
controlProps: state.appStates.startChatFailed ? errorUIControlProps : loadingPaneControlProps,
|
|
68
|
+
styleProps: state.appStates.startChatFailed ? errorUIStyleProps : loadingPaneStyleProps,
|
|
69
69
|
windowWidth: width,
|
|
70
70
|
windowHeight: height
|
|
71
71
|
});
|