@microsoft/omnichannel-chat-widget 1.4.1-main.22cb7d3 → 1.4.1-main.2575376
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +8 -11
- package/lib/cjs/components/livechatwidget/common/startChat.js +29 -15
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +8 -11
- package/lib/esm/components/livechatwidget/common/startChat.js +29 -15
- package/package.json +1 -1
|
@@ -65,17 +65,14 @@ const ChatButtonStateful = props => {
|
|
|
65
65
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
66
66
|
Event: _TelemetryConstants.TelemetryEvent.LCWChatButtonClicked
|
|
67
67
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
payload: _ConversationState.ConversationState.OutOfOffice
|
|
77
|
-
});
|
|
78
|
-
}
|
|
68
|
+
state.appStates.isMinimized && dispatch({
|
|
69
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
70
|
+
payload: false
|
|
71
|
+
});
|
|
72
|
+
dispatch({
|
|
73
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
74
|
+
payload: _ConversationState.ConversationState.OutOfOffice
|
|
75
|
+
});
|
|
79
76
|
},
|
|
80
77
|
unreadMessageString: (_props$buttonProps3 = props.buttonProps) === null || _props$buttonProps3 === void 0 ? void 0 : (_props$buttonProps3$c = _props$buttonProps3.controlProps) === null || _props$buttonProps3$c === void 0 ? void 0 : _props$buttonProps3$c.unreadMessageString,
|
|
81
78
|
...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
|
|
@@ -69,15 +69,29 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
69
69
|
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
70
70
|
const showPrechat = isProactiveChat ? preChatSurveyResponse && proactiveChatEnablePrechatState : preChatSurveyResponse && !(props !== null && props !== void 0 && (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hidePreChatSurveyPane);
|
|
71
71
|
if (showPrechat) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
var _state$domainStates, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3;
|
|
73
|
+
const isOutOfOperatingHours = (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$l = _state$domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : (_state$domainStates$l3 = _state$domainStates$l2.OutOfOperatingHours) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.toLowerCase()) === "true";
|
|
74
|
+
if (isOutOfOperatingHours) {
|
|
75
|
+
(state === null || state === void 0 ? void 0 : state.appStates.isMinimized) && dispatch({
|
|
76
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
77
|
+
payload: false
|
|
78
|
+
});
|
|
79
|
+
dispatch({
|
|
80
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
81
|
+
payload: _ConversationState.ConversationState.OutOfOffice
|
|
82
|
+
});
|
|
83
|
+
return;
|
|
84
|
+
} else {
|
|
85
|
+
dispatch({
|
|
86
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
87
|
+
payload: preChatSurveyResponse
|
|
88
|
+
});
|
|
89
|
+
dispatch({
|
|
90
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
91
|
+
payload: _ConversationState.ConversationState.Prechat
|
|
92
|
+
});
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
81
95
|
}
|
|
82
96
|
|
|
83
97
|
//Initiate start chat
|
|
@@ -303,17 +317,17 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
303
317
|
|
|
304
318
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
305
319
|
const setCustomContextParams = async (state, props) => {
|
|
306
|
-
var _props$chatConfig, _props$chatConfig$Liv, _state$
|
|
320
|
+
var _props$chatConfig, _props$chatConfig$Liv, _state$domainStates2, _persistedState$domai8;
|
|
307
321
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
308
322
|
const isAuthenticatedChat = props !== null && props !== void 0 && (_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction ? true : false;
|
|
309
323
|
//Should not set custom context for auth chat
|
|
310
324
|
if (isAuthenticatedChat) {
|
|
311
325
|
return;
|
|
312
326
|
}
|
|
313
|
-
if (state !== null && state !== void 0 && (_state$
|
|
314
|
-
var _state$
|
|
327
|
+
if (state !== null && state !== void 0 && (_state$domainStates2 = state.domainStates) !== null && _state$domainStates2 !== void 0 && _state$domainStates2.customContext) {
|
|
328
|
+
var _state$domainStates3;
|
|
315
329
|
optionalParams = Object.assign({}, optionalParams, {
|
|
316
|
-
customContext: JSON.parse(JSON.stringify(state === null || state === void 0 ? void 0 : (_state$
|
|
330
|
+
customContext: JSON.parse(JSON.stringify(state === null || state === void 0 ? void 0 : (_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : _state$domainStates3.customContext))
|
|
317
331
|
});
|
|
318
332
|
return;
|
|
319
333
|
}
|
|
@@ -361,8 +375,8 @@ const canStartPopoutChat = async props => {
|
|
|
361
375
|
|
|
362
376
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
363
377
|
const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
364
|
-
var _state$
|
|
365
|
-
const requestIdFromCache = (_state$
|
|
378
|
+
var _state$domainStates4, _state$domainStates4$;
|
|
379
|
+
const requestIdFromCache = (_state$domainStates4 = state.domainStates) === null || _state$domainStates4 === void 0 ? void 0 : (_state$domainStates4$ = _state$domainStates4.liveChatContext) === null || _state$domainStates4$ === void 0 ? void 0 : _state$domainStates4$.requestId;
|
|
366
380
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
367
381
|
let conversationDetails = undefined;
|
|
368
382
|
|
|
@@ -56,17 +56,14 @@ export const ChatButtonStateful = props => {
|
|
|
56
56
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
57
57
|
Event: TelemetryEvent.LCWChatButtonClicked
|
|
58
58
|
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
payload: ConversationState.OutOfOffice
|
|
68
|
-
});
|
|
69
|
-
}
|
|
59
|
+
state.appStates.isMinimized && dispatch({
|
|
60
|
+
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
61
|
+
payload: false
|
|
62
|
+
});
|
|
63
|
+
dispatch({
|
|
64
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
65
|
+
payload: ConversationState.OutOfOffice
|
|
66
|
+
});
|
|
70
67
|
},
|
|
71
68
|
unreadMessageString: (_props$buttonProps3 = props.buttonProps) === null || _props$buttonProps3 === void 0 ? void 0 : (_props$buttonProps3$c = _props$buttonProps3.controlProps) === null || _props$buttonProps3$c === void 0 ? void 0 : _props$buttonProps3$c.unreadMessageString,
|
|
72
69
|
...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
|
|
@@ -63,15 +63,29 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
63
63
|
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
64
64
|
const showPrechat = isProactiveChat ? preChatSurveyResponse && proactiveChatEnablePrechatState : preChatSurveyResponse && !(props !== null && props !== void 0 && (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hidePreChatSurveyPane);
|
|
65
65
|
if (showPrechat) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
var _state$domainStates, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3;
|
|
67
|
+
const isOutOfOperatingHours = (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$l = _state$domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : (_state$domainStates$l3 = _state$domainStates$l2.OutOfOperatingHours) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.toLowerCase()) === "true";
|
|
68
|
+
if (isOutOfOperatingHours) {
|
|
69
|
+
(state === null || state === void 0 ? void 0 : state.appStates.isMinimized) && dispatch({
|
|
70
|
+
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
71
|
+
payload: false
|
|
72
|
+
});
|
|
73
|
+
dispatch({
|
|
74
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
75
|
+
payload: ConversationState.OutOfOffice
|
|
76
|
+
});
|
|
77
|
+
return;
|
|
78
|
+
} else {
|
|
79
|
+
dispatch({
|
|
80
|
+
type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
81
|
+
payload: preChatSurveyResponse
|
|
82
|
+
});
|
|
83
|
+
dispatch({
|
|
84
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
85
|
+
payload: ConversationState.Prechat
|
|
86
|
+
});
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
75
89
|
}
|
|
76
90
|
|
|
77
91
|
//Initiate start chat
|
|
@@ -295,17 +309,17 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
295
309
|
|
|
296
310
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
297
311
|
const setCustomContextParams = async (state, props) => {
|
|
298
|
-
var _props$chatConfig, _props$chatConfig$Liv, _state$
|
|
312
|
+
var _props$chatConfig, _props$chatConfig$Liv, _state$domainStates2, _persistedState$domai8;
|
|
299
313
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
300
314
|
const isAuthenticatedChat = props !== null && props !== void 0 && (_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction ? true : false;
|
|
301
315
|
//Should not set custom context for auth chat
|
|
302
316
|
if (isAuthenticatedChat) {
|
|
303
317
|
return;
|
|
304
318
|
}
|
|
305
|
-
if (state !== null && state !== void 0 && (_state$
|
|
306
|
-
var _state$
|
|
319
|
+
if (state !== null && state !== void 0 && (_state$domainStates2 = state.domainStates) !== null && _state$domainStates2 !== void 0 && _state$domainStates2.customContext) {
|
|
320
|
+
var _state$domainStates3;
|
|
307
321
|
optionalParams = Object.assign({}, optionalParams, {
|
|
308
|
-
customContext: JSON.parse(JSON.stringify(state === null || state === void 0 ? void 0 : (_state$
|
|
322
|
+
customContext: JSON.parse(JSON.stringify(state === null || state === void 0 ? void 0 : (_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : _state$domainStates3.customContext))
|
|
309
323
|
});
|
|
310
324
|
return;
|
|
311
325
|
}
|
|
@@ -353,8 +367,8 @@ const canStartPopoutChat = async props => {
|
|
|
353
367
|
|
|
354
368
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
355
369
|
const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
356
|
-
var _state$
|
|
357
|
-
const requestIdFromCache = (_state$
|
|
370
|
+
var _state$domainStates4, _state$domainStates4$;
|
|
371
|
+
const requestIdFromCache = (_state$domainStates4 = state.domainStates) === null || _state$domainStates4 === void 0 ? void 0 : (_state$domainStates4$ = _state$domainStates4.liveChatContext) === null || _state$domainStates4$ === void 0 ? void 0 : _state$domainStates4$.requestId;
|
|
358
372
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
359
373
|
let conversationDetails = undefined;
|
|
360
374
|
|