@microsoft/omnichannel-chat-widget 0.1.0-main.21ab3ba → 0.1.0-main.23dc34f
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 +7 -34
- package/lib/cjs/common/Constants.js +2 -0
- package/lib/cjs/common/storage/default/defaultCacheManager.js +2 -2
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +15 -6
- package/lib/cjs/common/telemetry/TelemetryConstants.js +5 -0
- package/lib/cjs/common/telemetry/TelemetryHelper.js +2 -1
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +1 -1
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -2
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -10
- package/lib/cjs/components/livechatwidget/common/endChat.js +23 -17
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +25 -13
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +5 -5
- package/lib/cjs/components/livechatwidget/common/startChat.js +70 -59
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +43 -37
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +8 -1
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +4 -2
- package/lib/cjs/hooks/useDebounce.js +28 -0
- package/lib/cjs/hooks/useWindowDimensions.js +30 -0
- package/lib/cjs/plugins/newMessageEventHandler.js +14 -0
- package/lib/esm/common/Constants.js +2 -0
- package/lib/esm/common/storage/default/defaultCacheManager.js +2 -2
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +15 -6
- package/lib/esm/common/telemetry/TelemetryConstants.js +5 -0
- package/lib/esm/common/telemetry/TelemetryHelper.js +2 -1
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +1 -1
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
- package/lib/esm/components/headerstateful/HeaderStateful.js +4 -2
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -10
- package/lib/esm/components/livechatwidget/common/endChat.js +23 -17
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +25 -13
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +6 -5
- package/lib/esm/components/livechatwidget/common/startChat.js +70 -59
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +44 -38
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +8 -1
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +4 -2
- package/lib/esm/hooks/useDebounce.js +22 -0
- package/lib/esm/hooks/useWindowDimensions.js +23 -0
- package/lib/esm/plugins/newMessageEventHandler.js +14 -0
- package/lib/types/common/Constants.d.ts +2 -0
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +1 -1
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +1 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +6 -1
- package/lib/types/common/telemetry/definitions/Contracts.d.ts +2 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +1 -0
- package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +4 -0
- package/lib/types/components/livechatwidget/common/startChat.d.ts +3 -3
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +1 -1
- package/lib/types/hooks/useDebounce.d.ts +3 -0
- package/lib/types/hooks/useWindowDimensions.d.ts +4 -0
- package/package.json +3 -3
|
@@ -4,8 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.setPreChatAndInitiateChat = exports.prepareStartChat = exports.initStartChat = exports.checkIfConversationStillValid = void 0;
|
|
7
|
-
var _Constants = require("../../../common/Constants");
|
|
8
7
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
8
|
+
var _Constants = require("../../../common/Constants");
|
|
9
|
+
var _utils = require("../../../common/utils");
|
|
10
|
+
var _authHelper = require("./authHelper");
|
|
11
|
+
var _ActivityStreamHandler = require("./ActivityStreamHandler");
|
|
12
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
9
13
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
10
14
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
11
15
|
var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
|
|
@@ -14,13 +18,9 @@ var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
|
14
18
|
var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
15
19
|
var _createAdapter = require("./createAdapter");
|
|
16
20
|
var _newMessageEventHandler = require("../../../plugins/newMessageEventHandler");
|
|
17
|
-
var
|
|
21
|
+
var _reconnectChatHelper = require("./reconnectChatHelper");
|
|
18
22
|
var _setPostChatContextAndLoadSurvey = require("./setPostChatContextAndLoadSurvey");
|
|
19
23
|
var _updateSessionDataForTelemetry = require("./updateSessionDataForTelemetry");
|
|
20
|
-
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
21
|
-
var _ActivityStreamHandler = require("./ActivityStreamHandler");
|
|
22
|
-
var _authHelper = require("./authHelper");
|
|
23
|
-
var _reconnectChatHelper = require("./reconnectChatHelper");
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
25
|
let optionalParams = {};
|
|
26
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -84,12 +84,20 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
84
84
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
85
85
|
payload: _ConversationState.ConversationState.Loading
|
|
86
86
|
});
|
|
87
|
-
|
|
87
|
+
const optionalParams = {
|
|
88
|
+
isProactiveChat
|
|
89
|
+
};
|
|
90
|
+
await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
|
|
88
91
|
};
|
|
89
92
|
|
|
90
93
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
94
|
exports.setPreChatAndInitiateChat = setPreChatAndInitiateChat;
|
|
92
|
-
const initStartChat = async (chatSDK,
|
|
95
|
+
const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persistedState) => {
|
|
96
|
+
var _props$controlProps2;
|
|
97
|
+
let isStartChatSuccessful = false;
|
|
98
|
+
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
99
|
+
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
100
|
+
const hideErrorUIPane = props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.hideErrorUIPane;
|
|
93
101
|
try {
|
|
94
102
|
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
95
103
|
//Start widget load timer
|
|
@@ -103,10 +111,13 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
103
111
|
// set auth token to chat sdk before start chat
|
|
104
112
|
const authSuccess = await (0, _authHelper.handleAuthentication)(chatSDK, chatConfig, getAuthToken);
|
|
105
113
|
if (!authSuccess) {
|
|
114
|
+
dispatch({
|
|
115
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
116
|
+
payload: _ConversationState.ConversationState.Closed
|
|
117
|
+
});
|
|
106
118
|
return;
|
|
107
119
|
}
|
|
108
120
|
}
|
|
109
|
-
let isStartChatSuccessful = false;
|
|
110
121
|
|
|
111
122
|
//Check if chat retrieved from cache
|
|
112
123
|
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
@@ -120,10 +131,16 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
120
131
|
});
|
|
121
132
|
}
|
|
122
133
|
try {
|
|
134
|
+
var _window$Microsoft, _window$Microsoft$Dyn, _window$Microsoft$Dyn2, _window$Microsoft$Dyn3;
|
|
123
135
|
// Set custom context params
|
|
124
136
|
setCustomContextParams(chatSDK);
|
|
125
|
-
|
|
126
|
-
|
|
137
|
+
const defaultOptionalParams = {
|
|
138
|
+
sendDefaultInitContext: true,
|
|
139
|
+
isProactiveChat: !!(params !== null && params !== void 0 && params.isProactiveChat),
|
|
140
|
+
portalContactId: (_window$Microsoft = window.Microsoft) === null || _window$Microsoft === void 0 ? void 0 : (_window$Microsoft$Dyn = _window$Microsoft.Dynamic365) === null || _window$Microsoft$Dyn === void 0 ? void 0 : (_window$Microsoft$Dyn2 = _window$Microsoft$Dyn.Portal) === null || _window$Microsoft$Dyn2 === void 0 ? void 0 : (_window$Microsoft$Dyn3 = _window$Microsoft$Dyn2.User) === null || _window$Microsoft$Dyn3 === void 0 ? void 0 : _window$Microsoft$Dyn3.contactId
|
|
141
|
+
};
|
|
142
|
+
const startChatOptionalParams = Object.assign({}, params, optionalParams, defaultOptionalParams);
|
|
143
|
+
await chatSDK.startChat(startChatOptionalParams);
|
|
127
144
|
isStartChatSuccessful = true;
|
|
128
145
|
} catch (error) {
|
|
129
146
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
@@ -133,12 +150,6 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
133
150
|
}
|
|
134
151
|
});
|
|
135
152
|
isStartChatSuccessful = false;
|
|
136
|
-
// Resetting the widget state to Closed, for recent introduction of OC rate limiting(429 Error)
|
|
137
|
-
// TODO : How to diplay a proper UI message to customer to try after sometime at this point - cool down scenario
|
|
138
|
-
dispatch({
|
|
139
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
140
|
-
payload: _ConversationState.ConversationState.Closed
|
|
141
|
-
});
|
|
142
153
|
return;
|
|
143
154
|
}
|
|
144
155
|
|
|
@@ -167,12 +178,6 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
167
178
|
payload: liveChatContext
|
|
168
179
|
});
|
|
169
180
|
|
|
170
|
-
// Set post chat context in state, no survey load
|
|
171
|
-
(0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
|
|
172
|
-
|
|
173
|
-
// Updating chat session detail for telemetry
|
|
174
|
-
await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch);
|
|
175
|
-
|
|
176
181
|
// Set app state to Active
|
|
177
182
|
if (isStartChatSuccessful) {
|
|
178
183
|
_ActivityStreamHandler.ActivityStreamHandler.uncork();
|
|
@@ -191,6 +196,12 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
191
196
|
Description: "Widget load complete",
|
|
192
197
|
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
193
198
|
});
|
|
199
|
+
|
|
200
|
+
// Set post chat context in state, no survey load
|
|
201
|
+
(0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
|
|
202
|
+
|
|
203
|
+
// Updating chat session detail for telemetry
|
|
204
|
+
await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch);
|
|
194
205
|
} catch (ex) {
|
|
195
206
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
196
207
|
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
@@ -211,16 +222,28 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
211
222
|
});
|
|
212
223
|
return;
|
|
213
224
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
225
|
+
if (!hideErrorUIPane) {
|
|
226
|
+
// Set app state to failing start chat if hideErrorUI is not turned on
|
|
227
|
+
dispatch({
|
|
228
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
229
|
+
payload: true
|
|
230
|
+
});
|
|
231
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
232
|
+
Event: _TelemetryConstants.TelemetryEvent.ErrorUIPaneLoaded,
|
|
233
|
+
Description: "Error UI Pane Loaded"
|
|
234
|
+
});
|
|
235
|
+
}
|
|
219
236
|
// Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
|
|
220
237
|
dispatch({
|
|
221
238
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
222
239
|
payload: _ConversationState.ConversationState.Loading
|
|
223
240
|
});
|
|
241
|
+
|
|
242
|
+
// If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
|
|
243
|
+
// we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
|
|
244
|
+
if (isStartChatSuccessful === true) {
|
|
245
|
+
await forceEndChat(chatSDK);
|
|
246
|
+
}
|
|
224
247
|
} finally {
|
|
225
248
|
optionalParams = {};
|
|
226
249
|
widgetInstanceId = "";
|
|
@@ -229,16 +252,27 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
229
252
|
|
|
230
253
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
231
254
|
exports.initStartChat = initStartChat;
|
|
255
|
+
const forceEndChat = async chatSDK => {
|
|
256
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
257
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
258
|
+
ExceptionDetails: {
|
|
259
|
+
Exception: "SessionInit was successful, but widget load failed."
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat();
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
232
266
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
233
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$
|
|
267
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps3, _persistedState$domai6;
|
|
234
268
|
// By pass this function in case of popout chat
|
|
235
269
|
if (state.appStates.hideStartChatButton === true) {
|
|
236
270
|
return false;
|
|
237
271
|
}
|
|
238
|
-
const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId, (props === null || props === void 0 ? void 0 : (_props$
|
|
272
|
+
const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.widgetInstanceId) ?? "");
|
|
239
273
|
|
|
240
274
|
//Connect to only active chat session
|
|
241
|
-
if (persistedState && !(0, _utils.isUndefinedOrEmpty)(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai6 = persistedState.domainStates) === null || _persistedState$domai6 === void 0 ? void 0 : _persistedState$domai6.liveChatContext)
|
|
275
|
+
if (persistedState && !(0, _utils.isUndefinedOrEmpty)(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai6 = persistedState.domainStates) === null || _persistedState$domai6 === void 0 ? void 0 : _persistedState$domai6.liveChatContext)) {
|
|
242
276
|
var _persistedState$domai7;
|
|
243
277
|
dispatch({
|
|
244
278
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
@@ -247,7 +281,7 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
247
281
|
const optionalParams = {
|
|
248
282
|
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
|
|
249
283
|
};
|
|
250
|
-
await initStartChat(chatSDK,
|
|
284
|
+
await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
|
|
251
285
|
return true;
|
|
252
286
|
} else {
|
|
253
287
|
return false;
|
|
@@ -277,38 +311,11 @@ const setCustomContextParams = chatSDK => {
|
|
|
277
311
|
}
|
|
278
312
|
};
|
|
279
313
|
|
|
280
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
281
|
-
const handleAuthenticationIfEnabled = async (chatSDK, props) => {
|
|
282
|
-
//For auth chat
|
|
283
|
-
if (props.getAuthToken) {
|
|
284
|
-
const authClientFunction = (0, _authHelper.getAuthClientFunction)(props.chatConfig);
|
|
285
|
-
if (authClientFunction) {
|
|
286
|
-
// set auth token to chat sdk before start chat
|
|
287
|
-
const authSuccess = await (0, _authHelper.handleAuthentication)(chatSDK, props.chatConfig, props.getAuthToken);
|
|
288
|
-
if (!authSuccess) {
|
|
289
|
-
return false;
|
|
290
|
-
}
|
|
291
|
-
return true;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return true;
|
|
295
|
-
};
|
|
296
|
-
|
|
297
314
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
298
315
|
const checkIfConversationStillValid = async (chatSDK, props, requestId, dispatch) => {
|
|
299
316
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
300
317
|
let conversationDetails = undefined;
|
|
301
318
|
|
|
302
|
-
// Show Loading screen during auth check and start chat calls
|
|
303
|
-
dispatch({
|
|
304
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
305
|
-
payload: _ConversationState.ConversationState.Loading
|
|
306
|
-
});
|
|
307
|
-
const authSucceed = await handleAuthenticationIfEnabled(chatSDK, props);
|
|
308
|
-
if (!authSucceed) {
|
|
309
|
-
return false;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
319
|
//Preserve old requestId
|
|
313
320
|
const oldRequestId = chatSDK.requestId;
|
|
314
321
|
try {
|
|
@@ -319,6 +326,10 @@ const checkIfConversationStillValid = async (chatSDK, props, requestId, dispatch
|
|
|
319
326
|
return false;
|
|
320
327
|
}
|
|
321
328
|
if (conversationDetails.state === _Constants.LiveWorkItemState.Closed || conversationDetails.state === _Constants.LiveWorkItemState.WrapUp) {
|
|
329
|
+
dispatch({
|
|
330
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
331
|
+
payload: undefined
|
|
332
|
+
});
|
|
322
333
|
chatSDK.requestId = oldRequestId;
|
|
323
334
|
return false;
|
|
324
335
|
}
|
|
@@ -8,15 +8,18 @@ var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants"
|
|
|
8
8
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
9
9
|
var _react = require("@fluentui/react");
|
|
10
10
|
var _react2 = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _utils = require("../../../common/utils");
|
|
12
11
|
var _startChat = require("../common/startChat");
|
|
12
|
+
var _utils = require("../../../common/utils");
|
|
13
|
+
var _endChat = require("../common/endChat");
|
|
13
14
|
var _componentController = require("../../../controller/componentController");
|
|
15
|
+
var _ActivityStreamHandler = require("../common/ActivityStreamHandler");
|
|
14
16
|
var _CallingContainerStateful = _interopRequireDefault(require("../../callingcontainerstateful/CallingContainerStateful"));
|
|
15
17
|
var _ChatButtonStateful = _interopRequireDefault(require("../../chatbuttonstateful/ChatButtonStateful"));
|
|
16
18
|
var _botframeworkWebchat = require("botframework-webchat");
|
|
17
19
|
var _ConfirmationPaneStateful = _interopRequireDefault(require("../../confirmationpanestateful/ConfirmationPaneStateful"));
|
|
18
20
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
19
21
|
var _DataStoreManager = require("../../../common/contextDataStore/DataStoreManager");
|
|
22
|
+
var _Constants = require("../../../common/Constants");
|
|
20
23
|
var _EmailTranscriptPaneStateful = _interopRequireDefault(require("../../emailtranscriptpanestateful/EmailTranscriptPaneStateful"));
|
|
21
24
|
var _HeaderStateful = _interopRequireDefault(require("../../headerstateful/HeaderStateful"));
|
|
22
25
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
@@ -32,30 +35,27 @@ var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
|
32
35
|
var _WebChatContainerStateful = _interopRequireDefault(require("../../webchatcontainerstateful/WebChatContainerStateful"));
|
|
33
36
|
var _createFooter = require("../common/createFooter");
|
|
34
37
|
var _createInternetConnectionChangeHandler = require("../common/createInternetConnectionChangeHandler");
|
|
38
|
+
var _defaultClientDataStoreProvider = require("../../../common/storage/default/defaultClientDataStoreProvider");
|
|
39
|
+
var _defaultScrollBarProps = require("../common/defaultProps/defaultScrollBarProps");
|
|
35
40
|
var _defaultWebChatContainerStatefulProps = require("../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps");
|
|
36
41
|
var _disposeTelemetryLoggers = require("../common/disposeTelemetryLoggers");
|
|
37
|
-
var _endChat = require("../common/endChat");
|
|
38
42
|
var _getGeneralStylesForButton = require("../common/getGeneralStylesForButton");
|
|
39
43
|
var _initCallingSdk = require("../common/initCallingSdk");
|
|
40
44
|
var _initConfirmationPropsComposer = require("../common/initConfirmationPropsComposer");
|
|
41
45
|
var _initWebChatComposer = require("../common/initWebChatComposer");
|
|
46
|
+
var _defaultCacheManager = require("../../../common/storage/default/defaultCacheManager");
|
|
42
47
|
var _registerTelemetryLoggers = require("../common/registerTelemetryLoggers");
|
|
43
48
|
var _setPostChatContextAndLoadSurvey = require("../common/setPostChatContextAndLoadSurvey");
|
|
44
49
|
var _startProactiveChat = require("../common/startProactiveChat");
|
|
45
50
|
var _useChatAdapterStore = _interopRequireDefault(require("../../../hooks/useChatAdapterStore"));
|
|
46
51
|
var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useChatContextStore"));
|
|
47
52
|
var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDKStore"));
|
|
48
|
-
var _ActivityStreamHandler = require("../common/ActivityStreamHandler");
|
|
49
|
-
var _defaultCacheManager = require("../../../common/storage/default/defaultCacheManager");
|
|
50
|
-
var _defaultClientDataStoreProvider = require("../../../common/storage/default/defaultClientDataStoreProvider");
|
|
51
|
-
var _defaultScrollBarProps = require("../common/defaultProps/defaultScrollBarProps");
|
|
52
|
-
var _Constants = require("../../../common/Constants");
|
|
53
53
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
54
54
|
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); }
|
|
55
55
|
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; }
|
|
56
56
|
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); }
|
|
57
57
|
const LiveChatWidgetStateful = props => {
|
|
58
|
-
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$
|
|
58
|
+
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps14, _props$controlProps15, _props$componentOverr, _props$controlProps16, _props$componentOverr2, _props$controlProps17, _props$componentOverr3, _props$controlProps18, _props$componentOverr4, _props$controlProps19, _props$componentOverr5, _props$controlProps20, _props$componentOverr6, _props$controlProps21, _props$componentOverr7, _props$controlProps22, _props$controlProps23, _props$componentOverr8, _props$controlProps24, _props$componentOverr9, _props$controlProps25, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
59
59
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
60
60
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
61
|
const [adapter, setAdapter] = (0, _useChatAdapterStore.default)();
|
|
@@ -103,7 +103,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
103
103
|
};
|
|
104
104
|
} else {
|
|
105
105
|
activeCachedChatExist = false;
|
|
106
|
-
optionalParams =
|
|
106
|
+
optionalParams = {};
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
|
|
@@ -125,7 +125,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
125
125
|
//Check if conversation state is not in wrapup or closed state
|
|
126
126
|
isChatValid = await (0, _startChat.checkIfConversationStillValid)(chatSDK, props, (_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : (_state$domainStates3$ = _state$domainStates3.liveChatContext) === null || _state$domainStates3$ === void 0 ? void 0 : _state$domainStates3$.requestId, dispatch);
|
|
127
127
|
if (isChatValid === true) {
|
|
128
|
-
await (0, _startChat.initStartChat)(chatSDK,
|
|
128
|
+
await (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, props, optionalParams);
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
@@ -141,16 +141,22 @@ const LiveChatWidgetStateful = props => {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
146
|
+
const setupClientDataStore = () => {
|
|
146
147
|
// Add default localStorage support for widget
|
|
147
148
|
if (props.contextDataStore === undefined) {
|
|
148
|
-
var _chatSDK$omnichannelC2, _chatSDK$omnichannelC3, _props$
|
|
149
|
-
|
|
150
|
-
_DataStoreManager.DataStoreManager.clientDataStore = (0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)();
|
|
149
|
+
var _props$controlProps3, _chatSDK$omnichannelC2, _chatSDK$omnichannelC3, _props$controlProps4;
|
|
150
|
+
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;
|
|
151
|
+
_DataStoreManager.DataStoreManager.clientDataStore = (0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)(cacheTtlInMins);
|
|
152
|
+
(0, _defaultCacheManager.registerBroadcastServiceForLocalStorage)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.widgetInstanceId) ?? "", cacheTtlInMins);
|
|
151
153
|
} else {
|
|
152
154
|
_DataStoreManager.DataStoreManager.clientDataStore = props.contextDataStore;
|
|
153
155
|
}
|
|
156
|
+
};
|
|
157
|
+
(0, _react2.useEffect)(() => {
|
|
158
|
+
var _props$controlProps5, _props$controlProps6, _props$controlProps7, _props$chatConfig, _props$chatConfig$Liv, _props$controlProps9, _props$chatConfig2, _props$chatConfig2$Ch;
|
|
159
|
+
setupClientDataStore();
|
|
154
160
|
(0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
|
|
155
161
|
(0, _createInternetConnectionChangeHandler.createInternetConnectionChangeHandler)();
|
|
156
162
|
dispatch({
|
|
@@ -159,17 +165,17 @@ const LiveChatWidgetStateful = props => {
|
|
|
159
165
|
});
|
|
160
166
|
dispatch({
|
|
161
167
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_BUTTON_DISPLAY,
|
|
162
|
-
payload: ((_props$
|
|
168
|
+
payload: ((_props$controlProps5 = props.controlProps) === null || _props$controlProps5 === void 0 ? void 0 : _props$controlProps5.hideStartChatButton) || false
|
|
163
169
|
});
|
|
164
170
|
dispatch({
|
|
165
171
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
166
172
|
payload: false
|
|
167
173
|
});
|
|
168
|
-
if ((_props$
|
|
169
|
-
var _props$
|
|
174
|
+
if ((_props$controlProps6 = props.controlProps) !== null && _props$controlProps6 !== void 0 && _props$controlProps6.widgetInstanceId && !(0, _utils.isNullOrEmptyString)((_props$controlProps7 = props.controlProps) === null || _props$controlProps7 === void 0 ? void 0 : _props$controlProps7.widgetInstanceId)) {
|
|
175
|
+
var _props$controlProps8;
|
|
170
176
|
dispatch({
|
|
171
177
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID,
|
|
172
|
-
payload: (_props$
|
|
178
|
+
payload: (_props$controlProps8 = props.controlProps) === null || _props$controlProps8 === void 0 ? void 0 : _props$controlProps8.widgetInstanceId
|
|
173
179
|
});
|
|
174
180
|
}
|
|
175
181
|
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) {
|
|
@@ -182,7 +188,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
182
188
|
}
|
|
183
189
|
|
|
184
190
|
// Initialize global dir
|
|
185
|
-
const globalDir = ((_props$
|
|
191
|
+
const globalDir = ((_props$controlProps9 = props.controlProps) === null || _props$controlProps9 === void 0 ? void 0 : _props$controlProps9.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);
|
|
186
192
|
dispatch({
|
|
187
193
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_GLOBAL_DIR,
|
|
188
194
|
payload: globalDir
|
|
@@ -208,7 +214,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
208
214
|
|
|
209
215
|
// useEffect for custom context
|
|
210
216
|
(0, _react2.useEffect)(() => {
|
|
211
|
-
var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$
|
|
217
|
+
var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$controlProps12;
|
|
212
218
|
// Add the custom context on receiving the SetCustomContext event
|
|
213
219
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
214
220
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -238,12 +244,12 @@ const LiveChatWidgetStateful = props => {
|
|
|
238
244
|
|
|
239
245
|
// Start chat from SDK Event
|
|
240
246
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(() => {
|
|
241
|
-
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$
|
|
247
|
+
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$controlProps10;
|
|
242
248
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
243
249
|
Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
|
|
244
250
|
Description: "Start chat event received."
|
|
245
251
|
});
|
|
246
|
-
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$
|
|
252
|
+
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$controlProps10 = props.controlProps) === null || _props$controlProps10 === void 0 ? void 0 : _props$controlProps10.widgetInstanceId) ?? "");
|
|
247
253
|
|
|
248
254
|
// Chat not found in cache
|
|
249
255
|
if (persistedState === undefined) {
|
|
@@ -284,9 +290,9 @@ const LiveChatWidgetStateful = props => {
|
|
|
284
290
|
// End chat
|
|
285
291
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
286
292
|
if (state.appStates.hideStartChatButton === false) {
|
|
287
|
-
var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$
|
|
293
|
+
var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$controlProps11;
|
|
288
294
|
// This is to ensure to get latest state from cache in multitab
|
|
289
|
-
const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.widgetId, (props === null || props === void 0 ? void 0 : (_props$
|
|
295
|
+
const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
290
296
|
if (persistedState && persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
291
297
|
(0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
292
298
|
} else {
|
|
@@ -306,7 +312,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
306
312
|
});
|
|
307
313
|
|
|
308
314
|
// Listen to end chat event from other tabs
|
|
309
|
-
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC8 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC8 === void 0 ? void 0 : _chatSDK$omnichannelC8.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC9 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC9 === void 0 ? void 0 : _chatSDK$omnichannelC9.widgetId, ((_props$
|
|
315
|
+
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC8 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC8 === void 0 ? void 0 : _chatSDK$omnichannelC8.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC9 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC9 === void 0 ? void 0 : _chatSDK$omnichannelC9.widgetId, ((_props$controlProps12 = props.controlProps) === null || _props$controlProps12 === void 0 ? void 0 : _props$controlProps12.widgetInstanceId) ?? "");
|
|
310
316
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
311
317
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
312
318
|
return;
|
|
@@ -411,7 +417,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
411
417
|
|
|
412
418
|
// Publish chat widget state
|
|
413
419
|
(0, _react2.useEffect)(() => {
|
|
414
|
-
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$
|
|
420
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps13;
|
|
415
421
|
// Only activate these windows events when conversation state is active and chat widget is in popout mode
|
|
416
422
|
// Ghost chat scenarios
|
|
417
423
|
/* COMMENTING THIS CODE FOR PARITY WITH OLD LCW
|
|
@@ -429,7 +435,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
429
435
|
};
|
|
430
436
|
}*/
|
|
431
437
|
|
|
432
|
-
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, (props === null || props === void 0 ? void 0 : (_props$
|
|
438
|
+
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, (props === null || props === void 0 ? void 0 : (_props$controlProps13 = props.controlProps) === null || _props$controlProps13 === void 0 ? void 0 : _props$controlProps13.widgetInstanceId) ?? "");
|
|
433
439
|
const chatWidgetStateChangeEvent = {
|
|
434
440
|
eventName: widgetStateEventName,
|
|
435
441
|
payload: {
|
|
@@ -465,7 +471,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
465
471
|
const prepareEndChatRelay = (adapter, state) => (0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
466
472
|
const prepareStartChatRelay = () => (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
467
473
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
468
|
-
const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK,
|
|
474
|
+
const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
|
|
469
475
|
const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
|
|
470
476
|
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement("style", null, `
|
|
471
477
|
::-webkit-scrollbar {
|
|
@@ -491,29 +497,29 @@ const LiveChatWidgetStateful = props => {
|
|
|
491
497
|
id: widgetElementId,
|
|
492
498
|
styles: generalStyles,
|
|
493
499
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
494
|
-
}, !((_props$
|
|
500
|
+
}, !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideChatButton) && !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.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, {
|
|
495
501
|
buttonProps: props.chatButtonProps,
|
|
496
502
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
497
503
|
startChat: prepareStartChatRelay
|
|
498
|
-
})), !((_props$
|
|
504
|
+
})), !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.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, {
|
|
499
505
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
500
506
|
startChat: prepareStartChatRelay
|
|
501
|
-
})), !((_props$
|
|
507
|
+
})), !((_props$controlProps17 = props.controlProps) !== null && _props$controlProps17 !== void 0 && _props$controlProps17.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, {
|
|
502
508
|
headerProps: props.headerProps,
|
|
503
509
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
504
510
|
endChat: endChatRelay
|
|
505
|
-
})), !((_props$
|
|
511
|
+
})), !((_props$controlProps18 = props.controlProps) !== null && _props$controlProps18 !== void 0 && _props$controlProps18.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$controlProps19 = props.controlProps) !== null && _props$controlProps19 !== void 0 && _props$controlProps19.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$controlProps20 = props.controlProps) !== null && _props$controlProps20 !== void 0 && _props$controlProps20.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, {
|
|
506
512
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
507
513
|
initStartChat: initStartChatRelay
|
|
508
|
-
})), !((_props$
|
|
514
|
+
})), !((_props$controlProps21 = props.controlProps) !== null && _props$controlProps21 !== void 0 && _props$controlProps21.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, {
|
|
509
515
|
surveyProps: props.preChatSurveyPaneProps,
|
|
510
516
|
initStartChat: initStartChatRelay
|
|
511
|
-
})), !((_props$
|
|
517
|
+
})), !((_props$controlProps22 = props.controlProps) !== null && _props$controlProps22 !== void 0 && _props$controlProps22.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
|
|
512
518
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
513
|
-
}, props.callingContainerProps)), !((_props$
|
|
519
|
+
}, props.callingContainerProps)), !((_props$controlProps23 = props.controlProps) !== null && _props$controlProps23 !== void 0 && _props$controlProps23.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$controlProps24 = props.controlProps) !== null && _props$controlProps24 !== void 0 && _props$controlProps24.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, {
|
|
514
520
|
setPostChatContext: setPostChatContextRelay,
|
|
515
521
|
prepareEndChat: prepareEndChatRelay
|
|
516
|
-
}))), !((_props$
|
|
522
|
+
}))), !((_props$controlProps25 = props.controlProps) !== null && _props$controlProps25 !== void 0 && _props$controlProps25.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)))));
|
|
517
523
|
};
|
|
518
524
|
exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
|
|
519
525
|
var _default = LiveChatWidgetStateful;
|
|
@@ -11,6 +11,7 @@ var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
|
11
11
|
var _defaultgeneralLoadingPaneStyleProps = require("./common/defaultStyleProps/defaultgeneralLoadingPaneStyleProps");
|
|
12
12
|
var _utils = require("../../common/utils");
|
|
13
13
|
var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
|
|
14
|
+
var _useWindowDimensions = _interopRequireDefault(require("../../hooks/useWindowDimensions"));
|
|
14
15
|
var _errorUILoadingPaneStyleProps = require("./common/errorUIStyleProps/errorUILoadingPaneStyleProps");
|
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
17
|
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); }
|
|
@@ -40,6 +41,10 @@ const LoadingPaneStateful = props => {
|
|
|
40
41
|
hideSpinnerText: true,
|
|
41
42
|
...props.controlProps
|
|
42
43
|
};
|
|
44
|
+
const {
|
|
45
|
+
height,
|
|
46
|
+
width
|
|
47
|
+
} = (0, _useWindowDimensions.default)();
|
|
43
48
|
|
|
44
49
|
// Move focus to the first button
|
|
45
50
|
(0, _react.useEffect)(() => {
|
|
@@ -55,7 +60,9 @@ const LoadingPaneStateful = props => {
|
|
|
55
60
|
return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.LoadingPane, {
|
|
56
61
|
componentOverrides: props.componentOverrides,
|
|
57
62
|
controlProps: state.appStates.isStartChatFailing ? errorUIControlProps : controlProps,
|
|
58
|
-
styleProps: state.appStates.isStartChatFailing ? errorUIStyleProps : styleProps
|
|
63
|
+
styleProps: state.appStates.isStartChatFailing ? errorUIStyleProps : styleProps,
|
|
64
|
+
windowWidth: width,
|
|
65
|
+
windowHeight: height
|
|
59
66
|
});
|
|
60
67
|
};
|
|
61
68
|
exports.LoadingPaneStateful = LoadingPaneStateful;
|
|
@@ -120,7 +120,7 @@ const PreChatSurveyPaneStateful = props => {
|
|
|
120
120
|
}
|
|
121
121
|
if (current && current.tagName.toLowerCase() == _Constants.HtmlAttributeNames.div && current.childElementCount > 0) {
|
|
122
122
|
const input = current.children[0].children;
|
|
123
|
-
if (input
|
|
123
|
+
if ((input === null || input === void 0 ? void 0 : input.length) > 0 && input[0].className != _Constants.HtmlAttributeNames.adaptiveCardToggleInputClassName && input[0].className != _Constants.HtmlAttributeNames.adaptiveCardActionSetClassName) {
|
|
124
124
|
input[0].setAttribute(_Constants.HtmlAttributeNames.ariaLabel, value);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -7,7 +7,7 @@ exports.defaultGeneralPreChatSurveyPaneStyleProps = void 0;
|
|
|
7
7
|
const defaultGeneralPreChatSurveyPaneStyleProps = {
|
|
8
8
|
borderStyle: "solid",
|
|
9
9
|
borderRadius: "inherit",
|
|
10
|
-
borderWidth: "
|
|
10
|
+
borderWidth: "0px",
|
|
11
11
|
backgroundColor: "#FFFFFF",
|
|
12
12
|
borderColor: "#F1F1F1",
|
|
13
13
|
overflowY: "auto",
|
|
@@ -57,9 +57,7 @@ const activityStatusMiddleware = () => next => args => {
|
|
|
57
57
|
style: {
|
|
58
58
|
padding: "2px"
|
|
59
59
|
}
|
|
60
|
-
}, sendState === _SendStatus.SendStatus.Sending && /*#__PURE__*/_react.default.createElement(_SendingTimestamp.SendingTimestamp, {
|
|
61
|
-
args: args
|
|
62
|
-
}), sendState === _SendStatus.SendStatus.SendFailed && /*#__PURE__*/_react.default.createElement(_NotDeliveredTimestamp.NotDeliveredTimestamp, {
|
|
60
|
+
}, sendState === _SendStatus.SendStatus.Sending && /*#__PURE__*/_react.default.createElement(_SendingTimestamp.SendingTimestamp, null), sendState === _SendStatus.SendStatus.SendFailed && /*#__PURE__*/_react.default.createElement(_NotDeliveredTimestamp.NotDeliveredTimestamp, {
|
|
63
61
|
args: args
|
|
64
62
|
}), sendState === _SendStatus.SendStatus.Sent && /*#__PURE__*/_react.default.createElement(_DeliveredTimestamp.DeliveredTimestamp, {
|
|
65
63
|
args: args,
|
|
@@ -236,7 +236,8 @@ const createAttachmentMiddleware = enableInlinePlaying => {
|
|
|
236
236
|
renderer: next
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
|
-
|
|
239
|
+
const isUnknownImageObject = contentType.toLowerCase().includes("image") && !imageExtension;
|
|
240
|
+
if (fileExtension === "txt" || isUnknownImageObject) {
|
|
240
241
|
return /*#__PURE__*/_react.default.createElement(Attachment, {
|
|
241
242
|
iconData: iconData,
|
|
242
243
|
textCard: patchAttachment(card, {
|