@microsoft/omnichannel-chat-widget 0.1.0-main.e170704 → 0.1.0-main.f5f497a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/lib/cjs/common/Constants.js +14 -2
- package/lib/cjs/common/telemetry/TelemetryConstants.js +15 -3
- package/lib/cjs/common/telemetry/TelemetryManager.js +7 -1
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +8 -9
- package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/cjs/common/utils.js +17 -2
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +15 -3
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +7 -13
- package/lib/cjs/components/livechatwidget/common/endChat.js +28 -13
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +12 -3
- package/lib/cjs/components/livechatwidget/common/startChat.js +78 -31
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +147 -45
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -6
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
- package/lib/cjs/contexts/createReducer.js +9 -0
- package/lib/cjs/controller/componentController.js +1 -1
- package/lib/cjs/plugins/newMessageEventHandler.js +10 -13
- package/lib/esm/common/Constants.js +14 -2
- package/lib/esm/common/telemetry/TelemetryConstants.js +15 -3
- package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +8 -6
- package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/esm/common/utils.js +8 -0
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -6
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +7 -13
- package/lib/esm/components/livechatwidget/common/endChat.js +26 -14
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +11 -4
- package/lib/esm/components/livechatwidget/common/startChat.js +77 -34
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +139 -46
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +7 -8
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
- package/lib/esm/contexts/createReducer.js +9 -0
- package/lib/esm/controller/componentController.js +1 -1
- package/lib/esm/plugins/newMessageEventHandler.js +10 -12
- package/lib/types/common/Constants.d.ts +7 -1
- package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +17 -4
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
- package/lib/types/common/utils.d.ts +2 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.prepareStartChat = exports.initStartChat = void 0;
|
|
6
|
+
exports.setupChatState = exports.prepareStartChat = exports.initStartChat = void 0;
|
|
7
7
|
|
|
8
8
|
var _Constants = require("../../../common/Constants");
|
|
9
9
|
|
|
@@ -35,7 +35,11 @@ var _setPostChatContextAndLoadSurvey = require("./setPostChatContextAndLoadSurve
|
|
|
35
35
|
|
|
36
36
|
var _updateSessionDataForTelemetry = require("./updateSessionDataForTelemetry");
|
|
37
37
|
|
|
38
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
39
|
+
|
|
38
40
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
let optionalParams = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
|
|
39
43
|
const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
40
44
|
var _props$reconnectChatP;
|
|
41
45
|
|
|
@@ -49,11 +53,7 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
49
53
|
|
|
50
54
|
await (0, _reconnectChatHelper.handleRedirectUnauthenticatedReconnectChat)(chatSDK, dispatch, setAdapter, initStartChat, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.redirectInSameWindow);
|
|
51
55
|
} else {
|
|
52
|
-
// Getting
|
|
53
|
-
const parseToJson = false;
|
|
54
|
-
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
55
|
-
const showPrechat = state.appStates.conversationState === _ConversationState.ConversationState.ProactiveChat ? preChatSurveyResponse && state.appStates.proactiveChatStates.proactiveChatEnablePrechat : preChatSurveyResponse; // Getting reconnectId for authenticated chat
|
|
56
|
-
|
|
56
|
+
// Getting reconnectId for authenticated chat
|
|
57
57
|
const reconnectId = await (0, _reconnectChatHelper.getReconnectIdForAuthenticatedChat)(props, chatSDK);
|
|
58
58
|
|
|
59
59
|
if (reconnectId) {
|
|
@@ -65,32 +65,61 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
65
65
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
66
66
|
payload: _ConversationState.ConversationState.ReconnectChat
|
|
67
67
|
});
|
|
68
|
-
} else if (showPrechat) {
|
|
69
|
-
dispatch({
|
|
70
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
71
|
-
payload: preChatSurveyResponse
|
|
72
|
-
});
|
|
73
|
-
dispatch({
|
|
74
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
75
|
-
payload: _ConversationState.ConversationState.Prechat
|
|
76
|
-
});
|
|
77
68
|
} else {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
payload: _ConversationState.ConversationState.Loading
|
|
81
|
-
});
|
|
82
|
-
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
69
|
+
setCustomContextParams(props, state);
|
|
70
|
+
setupChatState(chatSDK, dispatch, setAdapter, state.appStates.conversationState === _ConversationState.ConversationState.ProactiveChat, state.appStates.proactiveChatStates.proactiveChatEnablePrechat);
|
|
83
71
|
}
|
|
84
72
|
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
exports.prepareStartChat = prepareStartChat;
|
|
76
|
+
|
|
77
|
+
const setupChatState = async (chatSDK, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState) => {
|
|
78
|
+
// Getting PreChat Survey Context
|
|
79
|
+
const parseToJson = false;
|
|
80
|
+
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
81
|
+
const showPrechat = isProactiveChat ? preChatSurveyResponse && proactiveChatEnablePrechatState : preChatSurveyResponse;
|
|
82
|
+
|
|
83
|
+
if (showPrechat) {
|
|
84
|
+
dispatch({
|
|
85
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
86
|
+
payload: preChatSurveyResponse
|
|
87
|
+
});
|
|
88
|
+
dispatch({
|
|
89
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
90
|
+
payload: _ConversationState.ConversationState.Prechat
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
dispatch({
|
|
94
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
95
|
+
payload: _ConversationState.ConversationState.Loading
|
|
96
|
+
});
|
|
97
|
+
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
98
|
+
}
|
|
85
99
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
100
|
|
|
87
101
|
|
|
88
|
-
exports.
|
|
102
|
+
exports.setupChatState = setupChatState;
|
|
89
103
|
|
|
90
104
|
const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedState) => {
|
|
91
105
|
try {
|
|
92
106
|
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
93
107
|
|
|
108
|
+
let isStartChatSuccessful = false;
|
|
109
|
+
|
|
110
|
+
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
111
|
+
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4, _persistedState$domai5;
|
|
112
|
+
|
|
113
|
+
// Broadcasting limited cached chat details
|
|
114
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
115
|
+
eventName: _TelemetryConstants.BroadcastEvent.ChatRetrievedFromCache,
|
|
116
|
+
payload: {
|
|
117
|
+
chatId: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : (_persistedState$domai2 = _persistedState$domai.liveChatContext) === null || _persistedState$domai2 === void 0 ? void 0 : (_persistedState$domai3 = _persistedState$domai2.chatToken) === null || _persistedState$domai3 === void 0 ? void 0 : _persistedState$domai3.chatId,
|
|
118
|
+
requestId: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai4 = persistedState.domainStates) === null || _persistedState$domai4 === void 0 ? void 0 : (_persistedState$domai5 = _persistedState$domai4.liveChatContext) === null || _persistedState$domai5 === void 0 ? void 0 : _persistedState$domai5.requestId
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
94
123
|
try {
|
|
95
124
|
_TelemetryManager.TelemetryTimers.WidgetLoadTimer = (0, _utils.createTimer)();
|
|
96
125
|
|
|
@@ -98,7 +127,9 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
98
127
|
Event: _TelemetryConstants.TelemetryEvent.StartChatSDKCall
|
|
99
128
|
});
|
|
100
129
|
|
|
101
|
-
|
|
130
|
+
optionalParams = Object.assign({}, params, optionalParams);
|
|
131
|
+
await chatSDK.startChat(optionalParams);
|
|
132
|
+
isStartChatSuccessful = true;
|
|
102
133
|
} catch (error) {
|
|
103
134
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
104
135
|
Event: _TelemetryConstants.TelemetryEvent.StartChatMethodException,
|
|
@@ -106,6 +137,8 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
106
137
|
exception: `Failed to setup startChat: ${error}`
|
|
107
138
|
}
|
|
108
139
|
});
|
|
140
|
+
|
|
141
|
+
isStartChatSuccessful = false;
|
|
109
142
|
}
|
|
110
143
|
|
|
111
144
|
const newAdapter = await (0, _createAdapter.createAdapter)(chatSDK);
|
|
@@ -133,10 +166,12 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
133
166
|
await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
|
|
134
167
|
await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch); // Set app state to Active
|
|
135
168
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
169
|
+
if (isStartChatSuccessful) {
|
|
170
|
+
dispatch({
|
|
171
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
172
|
+
payload: _ConversationState.ConversationState.Active
|
|
173
|
+
});
|
|
174
|
+
}
|
|
140
175
|
} else {
|
|
141
176
|
dispatch({
|
|
142
177
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
@@ -178,24 +213,36 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
178
213
|
exports.initStartChat = initStartChat;
|
|
179
214
|
|
|
180
215
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
181
|
-
var _DataStoreManager$cli, _persistedState$
|
|
216
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli, _persistedState$domai6;
|
|
182
217
|
|
|
183
|
-
const
|
|
218
|
+
const widgetStateEventName = (0, _utils.getWidgetCacheId)((chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId) ?? "", (chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId) ?? "");
|
|
219
|
+
const widgetStateFromCache = (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
|
|
184
220
|
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
185
221
|
|
|
186
|
-
if (persistedState !== null && persistedState !== void 0 && (_persistedState$
|
|
187
|
-
var _persistedState$
|
|
222
|
+
if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai6 = persistedState.domainStates) !== null && _persistedState$domai6 !== void 0 && _persistedState$domai6.liveChatContext) {
|
|
223
|
+
var _persistedState$domai7;
|
|
188
224
|
|
|
189
225
|
dispatch({
|
|
190
226
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
191
227
|
payload: _ConversationState.ConversationState.Loading
|
|
192
228
|
});
|
|
193
229
|
const optionalParams = {
|
|
194
|
-
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$
|
|
230
|
+
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
|
|
195
231
|
};
|
|
196
232
|
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
197
233
|
return true;
|
|
198
234
|
} else {
|
|
199
235
|
return false;
|
|
200
236
|
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const setCustomContextParams = (props, state) => {
|
|
240
|
+
var _props$chatConfig, _state$domainStates;
|
|
241
|
+
|
|
242
|
+
// Add custom context if any only for unauthenticated chat
|
|
243
|
+
if (!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) && (_state$domainStates = state.domainStates) !== null && _state$domainStates !== void 0 && _state$domainStates.customContext) {
|
|
244
|
+
optionalParams = Object.assign({}, optionalParams, {
|
|
245
|
+
customContext: state.domainStates.customContext
|
|
246
|
+
});
|
|
247
|
+
}
|
|
201
248
|
};
|
|
@@ -98,7 +98,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
98
98
|
function _extends() { _extends = Object.assign || 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); }
|
|
99
99
|
|
|
100
100
|
const LiveChatWidgetStateful = props => {
|
|
101
|
-
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$componentOverr, _props$
|
|
101
|
+
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$controlProps6, _props$componentOverr, _props$controlProps7, _props$componentOverr2, _props$controlProps8, _props$componentOverr3, _props$controlProps9, _props$componentOverr4, _props$controlProps10, _props$componentOverr5, _props$controlProps11, _props$componentOverr6, _props$controlProps12, _props$componentOverr7, _props$controlProps13, _props$controlProps14, _props$componentOverr8, _props$controlProps15, _props$componentOverr9, _props$controlProps16, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
102
102
|
|
|
103
103
|
const [state, dispatch] = (0, _useChatContextStore.default)(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
104
|
|
|
@@ -107,7 +107,8 @@ const LiveChatWidgetStateful = props => {
|
|
|
107
107
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles)
|
|
108
108
|
}); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
109
109
|
|
|
110
|
-
const chatSDK = (0, _useChatSDKStore.default)();
|
|
110
|
+
const chatSDK = (0, _useChatSDKStore.default)(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
|
+
|
|
111
112
|
const [voiceVideoCallingSDK, setVoiceVideoCallingSDK] = (0, _react2.useState)(undefined);
|
|
112
113
|
const {
|
|
113
114
|
Composer
|
|
@@ -121,6 +122,33 @@ const LiveChatWidgetStateful = props => {
|
|
|
121
122
|
_TelemetryManager.TelemetryTimers.LcwLoadToChatButtonTimer = (0, _utils.createTimer)();
|
|
122
123
|
const widgetElementId = ((_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.id) || "oc-lcw";
|
|
123
124
|
const currentMessageCountRef = (0, _react2.useRef)(0);
|
|
125
|
+
let widgetStateEventName = "";
|
|
126
|
+
|
|
127
|
+
const initiateEndChatOnBrowserUnload = () => {
|
|
128
|
+
var _DataStoreManager$cli;
|
|
129
|
+
|
|
130
|
+
const persistedState = getStateFromCache(); // End chat if the chat is still active and browser closed
|
|
131
|
+
|
|
132
|
+
if (persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
133
|
+
//Browser close scenario/no room for PCS/so just end chat and notify agent immidiately
|
|
134
|
+
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
135
|
+
} // Clean local storage
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
(_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage");
|
|
139
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
const getStateFromCache = () => {
|
|
143
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli2;
|
|
144
|
+
|
|
145
|
+
// Getting updated state from cache
|
|
146
|
+
const widgetStateEventName = (0, _utils.getWidgetCacheId)((chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId) ?? "", (chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId) ?? "");
|
|
147
|
+
const widgetStateFromCache = (_DataStoreManager$cli2 = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli2 === void 0 ? void 0 : _DataStoreManager$cli2.getData(widgetStateEventName, "localStorage");
|
|
148
|
+
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
149
|
+
return persistedState;
|
|
150
|
+
};
|
|
151
|
+
|
|
124
152
|
(0, _react2.useEffect)(() => {
|
|
125
153
|
var _props$controlProps2, _props$controlProps3, _props$reconnectChatP, _props$controlProps4, _props$chatConfig, _props$chatConfig$Cha, _state$domainStates;
|
|
126
154
|
|
|
@@ -135,6 +163,10 @@ const LiveChatWidgetStateful = props => {
|
|
|
135
163
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SKIP_CHAT_BUTTON_RENDERING,
|
|
136
164
|
payload: ((_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.skipChatButtonRendering) || false
|
|
137
165
|
});
|
|
166
|
+
dispatch({
|
|
167
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
168
|
+
payload: false
|
|
169
|
+
});
|
|
138
170
|
(0, _initCallingSdk.initCallingSdk)(chatSDK, setVoiceVideoCallingSDK).then(sdkCreated => {
|
|
139
171
|
sdkCreated && dispatch({
|
|
140
172
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
@@ -163,11 +195,16 @@ const LiveChatWidgetStateful = props => {
|
|
|
163
195
|
};
|
|
164
196
|
(0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams);
|
|
165
197
|
}
|
|
166
|
-
}, []);
|
|
198
|
+
}, []); // useEffect for when skip chat button rendering
|
|
199
|
+
|
|
167
200
|
(0, _react2.useEffect)(() => {
|
|
168
201
|
if (state.appStates.skipChatButtonRendering) {
|
|
169
202
|
var _props$reconnectChatP3;
|
|
170
203
|
|
|
204
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
205
|
+
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
206
|
+
});
|
|
207
|
+
|
|
171
208
|
if ((_props$reconnectChatP3 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP3 !== void 0 && _props$reconnectChatP3.reconnectId && !state.appStates.reconnectId) {
|
|
172
209
|
var _props$reconnectChatP4, _props$reconnectChatP5;
|
|
173
210
|
|
|
@@ -190,17 +227,16 @@ const LiveChatWidgetStateful = props => {
|
|
|
190
227
|
|
|
191
228
|
_omnichannelChatComponents.BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
|
|
192
229
|
|
|
193
|
-
dispatch
|
|
194
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
195
|
-
payload: _ConversationState.ConversationState.Loading
|
|
196
|
-
});
|
|
197
|
-
(0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter);
|
|
230
|
+
(0, _startChat.setupChatState)(chatSDK, dispatch, setAdapter);
|
|
198
231
|
}
|
|
199
232
|
});
|
|
200
233
|
}
|
|
201
234
|
}
|
|
202
|
-
}, [state.appStates.skipChatButtonRendering]);
|
|
235
|
+
}, [state.appStates.skipChatButtonRendering]); // useEffect for when skip chat button rendering
|
|
236
|
+
|
|
203
237
|
(0, _react2.useEffect)(() => {
|
|
238
|
+
var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4;
|
|
239
|
+
|
|
204
240
|
// Add the custom context on receiving the SetCustomContext event
|
|
205
241
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
206
242
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -214,7 +250,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
214
250
|
});
|
|
215
251
|
});
|
|
216
252
|
|
|
217
|
-
_omnichannelChatComponents.BroadcastService.getMessageByEventName(
|
|
253
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartProactiveChat).subscribe(msg => {
|
|
218
254
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
219
255
|
Event: _TelemetryConstants.TelemetryEvent.StartProactiveChatEventReceived,
|
|
220
256
|
Description: "Start proactive chat event received."
|
|
@@ -230,32 +266,52 @@ const LiveChatWidgetStateful = props => {
|
|
|
230
266
|
Description: "Start proactive chat method called, when chat was already triggered."
|
|
231
267
|
});
|
|
232
268
|
}
|
|
233
|
-
}); //
|
|
269
|
+
}); // Start chat from SDK Event
|
|
234
270
|
|
|
235
271
|
|
|
236
|
-
_omnichannelChatComponents.BroadcastService.getMessageByEventName(
|
|
272
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(() => {
|
|
237
273
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
238
274
|
Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
|
|
239
275
|
Description: "Start chat event received."
|
|
240
276
|
});
|
|
241
277
|
|
|
242
|
-
|
|
278
|
+
const persistedState = getStateFromCache();
|
|
279
|
+
|
|
280
|
+
if (persistedState && (persistedState.appStates.conversationState === _ConversationState.ConversationState.Closed || persistedState.appStates.conversationState === _ConversationState.ConversationState.InActive || persistedState.appStates.conversationState === _ConversationState.ConversationState.Postchat)) {
|
|
281
|
+
// Embedded mode
|
|
282
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
283
|
+
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
(0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
287
|
+
} else if (!persistedState) {
|
|
288
|
+
// Popout chat
|
|
289
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
290
|
+
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
(0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
294
|
+
} else {
|
|
295
|
+
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4;
|
|
296
|
+
|
|
297
|
+
// Minimize to Maximize
|
|
243
298
|
dispatch({
|
|
244
299
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
245
300
|
payload: false
|
|
246
301
|
});
|
|
247
|
-
} else {
|
|
248
|
-
(0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
249
|
-
}
|
|
250
|
-
}); // end chat from SDK Event
|
|
251
302
|
|
|
303
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
304
|
+
eventName: _TelemetryConstants.BroadcastEvent.MaximizeChat,
|
|
305
|
+
payload: {
|
|
306
|
+
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,
|
|
307
|
+
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
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}); // End chat
|
|
252
312
|
|
|
253
|
-
_omnichannelChatComponents.BroadcastService.getMessageByEventName("EndChat").subscribe(async () => {
|
|
254
|
-
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
255
|
-
Event: _TelemetryConstants.TelemetryEvent.EndChatEventReceived,
|
|
256
|
-
Description: "End chat event received."
|
|
257
|
-
});
|
|
258
313
|
|
|
314
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
259
315
|
if (canEndChat.current) {
|
|
260
316
|
(0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
261
317
|
} else {
|
|
@@ -263,18 +319,58 @@ const LiveChatWidgetStateful = props => {
|
|
|
263
319
|
const skipCloseChat = false;
|
|
264
320
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
|
|
265
321
|
}
|
|
322
|
+
|
|
323
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
324
|
+
eventName: _TelemetryConstants.BroadcastEvent.CloseChat
|
|
325
|
+
});
|
|
266
326
|
});
|
|
267
327
|
|
|
328
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChatOnBrowserUnload).subscribe(() => {
|
|
329
|
+
initiateEndChatOnBrowserUnload();
|
|
330
|
+
}); // reset proactive chat params
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.ResetProactiveChatParams).subscribe(async () => {
|
|
334
|
+
dispatch({
|
|
335
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
336
|
+
payload: {
|
|
337
|
+
proactiveChatBodyTitle: "",
|
|
338
|
+
proactiveChatEnablePrechat: false,
|
|
339
|
+
proactiveChatInNewWindow: false
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}); // Listen to end chat event from other tabs
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.widgetId);
|
|
346
|
+
|
|
347
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
348
|
+
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
349
|
+
}); // Close popout window
|
|
350
|
+
|
|
351
|
+
|
|
268
352
|
window.addEventListener("beforeunload", () => {
|
|
353
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
354
|
+
Event: _TelemetryConstants.TelemetryEvent.WindowClosed,
|
|
355
|
+
Description: "Closed window."
|
|
356
|
+
});
|
|
357
|
+
|
|
269
358
|
(0, _disposeTelemetryLoggers.disposeTelemetryLoggers)();
|
|
270
359
|
});
|
|
271
360
|
|
|
272
361
|
if (state.appStates.conversationEndedByAgent) {
|
|
273
362
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
|
|
274
|
-
}
|
|
363
|
+
} //Listen to WidgetSize
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName("WidgetSize").subscribe(msg => {
|
|
367
|
+
dispatch({
|
|
368
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_SIZE,
|
|
369
|
+
payload: msg === null || msg === void 0 ? void 0 : msg.payload
|
|
370
|
+
});
|
|
371
|
+
});
|
|
275
372
|
}, []);
|
|
276
373
|
(0, _react2.useEffect)(() => {
|
|
277
|
-
canStartProactiveChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Closed;
|
|
278
374
|
canEndChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Active;
|
|
279
375
|
|
|
280
376
|
if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
@@ -295,7 +391,10 @@ const LiveChatWidgetStateful = props => {
|
|
|
295
391
|
});
|
|
296
392
|
});
|
|
297
393
|
}
|
|
298
|
-
}, [state.appStates.conversationState]);
|
|
394
|
+
}, [state.appStates.conversationState]);
|
|
395
|
+
(0, _react2.useEffect)(() => {
|
|
396
|
+
canStartProactiveChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Closed && !state.appStates.proactiveChatStates.proactiveChatInNewWindow;
|
|
397
|
+
}, [state.appStates.conversationState, state.appStates.proactiveChatStates.proactiveChatInNewWindow]); // Reset the UnreadMessageCount when minimized is toggled and broadcast it.
|
|
299
398
|
|
|
300
399
|
(0, _react2.useEffect)(() => {
|
|
301
400
|
currentMessageCountRef.current = -1;
|
|
@@ -329,7 +428,20 @@ const LiveChatWidgetStateful = props => {
|
|
|
329
428
|
setWebChatStyles({ ...webChatStyles,
|
|
330
429
|
...((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.webChatStyles)
|
|
331
430
|
});
|
|
332
|
-
}, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]);
|
|
431
|
+
}, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]); // Publish chat widget state
|
|
432
|
+
|
|
433
|
+
(0, _react2.useEffect)(() => {
|
|
434
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic;
|
|
435
|
+
|
|
436
|
+
widgetStateEventName = (0, _utils.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);
|
|
437
|
+
const chatWidgetStateChangeEvent = {
|
|
438
|
+
eventName: widgetStateEventName,
|
|
439
|
+
payload: { ...state
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
_omnichannelChatComponents.BroadcastService.postMessage(chatWidgetStateChangeEvent);
|
|
444
|
+
}, [state]);
|
|
333
445
|
const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, chatSDK, state, dispatch, setWebChatStyles);
|
|
334
446
|
|
|
335
447
|
const setPostChatContextRelay = () => (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -345,17 +457,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
345
457
|
|
|
346
458
|
const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
347
459
|
|
|
348
|
-
const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
|
|
349
|
-
|
|
350
|
-
(0, _react2.useEffect)(() => {
|
|
351
|
-
const chatWidgetStateChangeEvent = {
|
|
352
|
-
eventName: _TelemetryConstants.BroadcastEvent.ChatWidgetStateChanged,
|
|
353
|
-
payload: { ...state
|
|
354
|
-
}
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
_omnichannelChatComponents.BroadcastService.postMessage(chatWidgetStateChangeEvent);
|
|
358
|
-
}, [state]);
|
|
460
|
+
const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
|
|
359
461
|
return /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
|
|
360
462
|
styleOptions: webChatStyles,
|
|
361
463
|
directLine: ((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.directLine) ?? adapter ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.directLine
|
|
@@ -363,29 +465,29 @@ const LiveChatWidgetStateful = props => {
|
|
|
363
465
|
id: widgetElementId,
|
|
364
466
|
styles: generalStyles,
|
|
365
467
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
366
|
-
}, !((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.hideChatButton) && (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, {
|
|
468
|
+
}, !((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.hideChatButton) && !((_props$controlProps6 = props.controlProps) !== null && _props$controlProps6 !== void 0 && _props$controlProps6.skipChatButtonRendering) && (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, {
|
|
367
469
|
buttonProps: props.chatButtonProps,
|
|
368
470
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
369
471
|
startChat: prepareStartChatRelay
|
|
370
|
-
})), !((_props$
|
|
472
|
+
})), !((_props$controlProps7 = props.controlProps) !== null && _props$controlProps7 !== void 0 && _props$controlProps7.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, {
|
|
371
473
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
372
474
|
startChat: prepareStartChatRelay
|
|
373
|
-
})), !((_props$
|
|
475
|
+
})), !((_props$controlProps8 = props.controlProps) !== null && _props$controlProps8 !== void 0 && _props$controlProps8.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, {
|
|
374
476
|
headerProps: props.headerProps,
|
|
375
477
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
376
478
|
endChat: endChatRelay
|
|
377
|
-
})), !((_props$
|
|
479
|
+
})), !((_props$controlProps9 = props.controlProps) !== null && _props$controlProps9 !== void 0 && _props$controlProps9.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, props.loadingPaneProps)), !((_props$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.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$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.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, {
|
|
378
480
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
379
481
|
initStartChat: initStartChatRelay
|
|
380
|
-
})), !((_props$
|
|
482
|
+
})), !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.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, {
|
|
381
483
|
surveyProps: props.preChatSurveyPaneProps,
|
|
382
484
|
initStartChat: initStartChatRelay
|
|
383
|
-
})), !((_props$
|
|
485
|
+
})), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
|
|
384
486
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
385
|
-
}, props.callingContainerProps)), !((_props$
|
|
487
|
+
}, props.callingContainerProps)), !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.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$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.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, {
|
|
386
488
|
setPostChatContext: setPostChatContextRelay,
|
|
387
489
|
prepareEndChat: prepareEndChatRelay
|
|
388
|
-
}))), !((_props$
|
|
490
|
+
}))), !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.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))));
|
|
389
491
|
};
|
|
390
492
|
|
|
391
493
|
exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
|
|
@@ -93,13 +93,14 @@ const PreChatSurveyPaneStateful = props => {
|
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
try {
|
|
96
|
-
var _DataStoreManager$cli, _persistedState$domai;
|
|
96
|
+
var _state$domainStates, _state$domainStates$t, _state$domainStates$t2, _DataStoreManager$cli, _persistedState$domai;
|
|
97
97
|
|
|
98
|
-
const
|
|
98
|
+
const widgetStateCacheId = (0, _utils.getWidgetCacheId)(((_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) ?? "");
|
|
99
|
+
const widgetStateFromCache = (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateCacheId, "localStorage");
|
|
99
100
|
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
100
101
|
let optionalParams = {};
|
|
101
102
|
|
|
102
|
-
if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai = persistedState.domainStates) !== null && _persistedState$domai !== void 0 && _persistedState$domai.liveChatContext) {
|
|
103
|
+
if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai = persistedState.domainStates) !== null && _persistedState$domai !== void 0 && _persistedState$domai.liveChatContext && !state.appStates.skipChatButtonRendering) {
|
|
103
104
|
var _persistedState$domai2;
|
|
104
105
|
|
|
105
106
|
optionalParams = {
|
|
@@ -109,9 +110,7 @@ const PreChatSurveyPaneStateful = props => {
|
|
|
109
110
|
} else {
|
|
110
111
|
const prechatResponseValues = (0, _utils.extractPreChatSurveyResponseValues)(state.domainStates.preChatSurveyResponse, values);
|
|
111
112
|
optionalParams = {
|
|
112
|
-
|
|
113
|
-
preChatResponse: prechatResponseValues
|
|
114
|
-
}
|
|
113
|
+
preChatResponse: prechatResponseValues
|
|
115
114
|
};
|
|
116
115
|
setPreChatResponseEmail(values);
|
|
117
116
|
await initStartChat(optionalParams);
|
|
@@ -46,6 +46,14 @@ const ProactiveChatPaneStateful = props => {
|
|
|
46
46
|
const handleProactiveChatInviteTimeout = () => {
|
|
47
47
|
if (!timeoutRemoved) {
|
|
48
48
|
setTimeoutRemoved(true);
|
|
49
|
+
dispatch({
|
|
50
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
51
|
+
payload: {
|
|
52
|
+
proactiveChatBodyTitle: "",
|
|
53
|
+
proactiveChatEnablePrechat: false,
|
|
54
|
+
proactiveChatInNewWindow: false
|
|
55
|
+
}
|
|
56
|
+
});
|
|
49
57
|
dispatch({
|
|
50
58
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
51
59
|
payload: _ConversationState.ConversationState.Closed
|
|
@@ -111,13 +119,21 @@ const ProactiveChatPaneStateful = props => {
|
|
|
111
119
|
Description: "Proactive chat closed."
|
|
112
120
|
});
|
|
113
121
|
|
|
122
|
+
dispatch({
|
|
123
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
124
|
+
payload: {
|
|
125
|
+
proactiveChatBodyTitle: "",
|
|
126
|
+
proactiveChatEnablePrechat: false,
|
|
127
|
+
proactiveChatInNewWindow: false
|
|
128
|
+
}
|
|
129
|
+
});
|
|
114
130
|
dispatch({
|
|
115
131
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
116
132
|
payload: _ConversationState.ConversationState.Closed
|
|
117
133
|
});
|
|
118
134
|
},
|
|
119
135
|
...(proactiveChatProps === null || proactiveChatProps === void 0 ? void 0 : proactiveChatProps.controlProps),
|
|
120
|
-
bodyTitleText: state.appStates.proactiveChatStates.proactiveChatBodyTitle
|
|
136
|
+
bodyTitleText: state.appStates.proactiveChatStates.proactiveChatBodyTitle ? state.appStates.proactiveChatStates.proactiveChatBodyTitle : proactiveChatProps === null || proactiveChatProps === void 0 ? void 0 : (_proactiveChatProps$c = proactiveChatProps.controlProps) === null || _proactiveChatProps$c === void 0 ? void 0 : _proactiveChatProps$c.bodyTitleText
|
|
121
137
|
};
|
|
122
138
|
(0, _react.useEffect)(() => {
|
|
123
139
|
(0, _utils.setFocusOnElement)(document.getElementById(controlProps.id + "-startbutton"));
|