@microsoft/omnichannel-chat-widget 0.1.0-main.c881067 → 0.1.0-main.c91fa67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/common/Constants.js +2 -0
- package/lib/cjs/common/storage/default/defaultCacheManager.js +2 -2
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +7 -3
- package/lib/cjs/common/telemetry/TelemetryConstants.js +5 -0
- package/lib/cjs/components/headerstateful/HeaderStateful.js +1 -1
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +6 -3
- 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 +3 -3
- package/lib/cjs/components/livechatwidget/common/startChat.js +53 -51
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +35 -29
- 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/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 +11 -1
- 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 +7 -3
- package/lib/esm/common/telemetry/TelemetryConstants.js +5 -0
- package/lib/esm/components/headerstateful/HeaderStateful.js +1 -1
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +6 -3
- 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 +3 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +53 -51
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +36 -30
- 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/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 +11 -1
- 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/components/livechatwidget/common/startChat.d.ts +2 -3
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +2 -0
- package/lib/types/hooks/useDebounce.d.ts +3 -0
- package/lib/types/hooks/useWindowDimensions.d.ts +4 -0
- package/package.json +3 -3
|
@@ -89,6 +89,7 @@ _defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect
|
|
|
89
89
|
_defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
|
|
90
90
|
_defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
|
|
91
91
|
_defineProperty(Constants, "BrowserUnloadConfirmationMessage", "Do you want to leave chat?");
|
|
92
|
+
_defineProperty(Constants, "CacheTtlInMinutes", 15);
|
|
92
93
|
const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
|
|
93
94
|
exports.Regex = Regex;
|
|
94
95
|
class HtmlIdNames {}
|
|
@@ -134,6 +135,7 @@ _defineProperty(HtmlAttributeNames, "noreferrerTag", "noreferrer");
|
|
|
134
135
|
_defineProperty(HtmlAttributeNames, "adaptiveCardClassName", "ac-adaptiveCard");
|
|
135
136
|
_defineProperty(HtmlAttributeNames, "adaptiveCardTextBlockClassName", "ac-textBlock");
|
|
136
137
|
_defineProperty(HtmlAttributeNames, "adaptiveCardToggleInputClassName", "ac-toggleInput");
|
|
138
|
+
_defineProperty(HtmlAttributeNames, "adaptiveCardActionSetClassName", "ac-actionSet");
|
|
137
139
|
class WebChatMiddlewareConstants {}
|
|
138
140
|
exports.WebChatMiddlewareConstants = WebChatMiddlewareConstants;
|
|
139
141
|
_defineProperty(WebChatMiddlewareConstants, "nextVisibleActivity", "nextVisibleActivity");
|
|
@@ -13,11 +13,11 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
13
13
|
class defaultCacheManager {}
|
|
14
14
|
exports.defaultCacheManager = defaultCacheManager;
|
|
15
15
|
_defineProperty(defaultCacheManager, "InternalCache", {});
|
|
16
|
-
const registerBroadcastServiceForLocalStorage = (orgid, widgetId, widgetInstanceId) => {
|
|
16
|
+
const registerBroadcastServiceForLocalStorage = (orgid, widgetId, widgetInstanceId, ttlInMins) => {
|
|
17
17
|
const widgetCacheId = (0, _utils.getWidgetCacheId)(orgid, widgetId, widgetInstanceId);
|
|
18
18
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(widgetCacheId).subscribe(msg => {
|
|
19
19
|
try {
|
|
20
|
-
(0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)().setData(widgetCacheId, JSON.stringify(msg.payload), "localStorage");
|
|
20
|
+
(0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)(ttlInMins).setData(widgetCacheId, JSON.stringify(msg.payload), "localStorage");
|
|
21
21
|
} catch (error) {
|
|
22
22
|
console.error("Error in setting data to localstorage", error);
|
|
23
23
|
}
|
|
@@ -9,7 +9,9 @@ var _TelemetryHelper = require("../../telemetry/TelemetryHelper");
|
|
|
9
9
|
var _defaultInMemoryDataStore = require("./defaultInMemoryDataStore");
|
|
10
10
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
11
11
|
|
|
12
|
-
const defaultClientDataStoreProvider = ()
|
|
12
|
+
const defaultClientDataStoreProvider = function () {
|
|
13
|
+
let cacheTtlinMins = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
14
|
+
let ttlInMs = 0;
|
|
13
15
|
const isCookieAllowed = () => {
|
|
14
16
|
try {
|
|
15
17
|
localStorage;
|
|
@@ -23,7 +25,9 @@ const defaultClientDataStoreProvider = () => {
|
|
|
23
25
|
return false;
|
|
24
26
|
}
|
|
25
27
|
};
|
|
26
|
-
|
|
28
|
+
if (ttlInMs == 0) {
|
|
29
|
+
ttlInMs = cacheTtlinMins * 60 * 1000;
|
|
30
|
+
}
|
|
27
31
|
const dataStoreProvider = {
|
|
28
32
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
33
|
setData: (key, data, type) => {
|
|
@@ -33,7 +37,7 @@ const defaultClientDataStoreProvider = () => {
|
|
|
33
37
|
const now = new Date();
|
|
34
38
|
const item = {
|
|
35
39
|
data: data,
|
|
36
|
-
expiry: now.getTime() +
|
|
40
|
+
expiry: now.getTime() + ttlInMs
|
|
37
41
|
};
|
|
38
42
|
const strItem = JSON.stringify(item);
|
|
39
43
|
if (type === "localStorage") {
|
|
@@ -54,6 +54,8 @@ exports.BroadcastEvent = BroadcastEvent;
|
|
|
54
54
|
BroadcastEvent["InitiateEndChatOnBrowserUnload"] = "InitiateEndChatOnBrowserUnload";
|
|
55
55
|
BroadcastEvent["ClosePopoutWindow"] = "ClosePopoutWindow";
|
|
56
56
|
BroadcastEvent["RaiseErrorEvent"] = "RaiseErrorEvent";
|
|
57
|
+
BroadcastEvent["NetworkDisconnected"] = "NetworkDisconnected";
|
|
58
|
+
BroadcastEvent["NetworkReconnected"] = "NetworkReconnected";
|
|
57
59
|
})(BroadcastEvent || (exports.BroadcastEvent = BroadcastEvent = {}));
|
|
58
60
|
let TelemetryEvent;
|
|
59
61
|
exports.TelemetryEvent = TelemetryEvent;
|
|
@@ -115,6 +117,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
115
117
|
TelemetryEvent["DownloadTranscriptResponseNullOrUndefined"] = "DownloadTranscriptResponseNullOrUndefined";
|
|
116
118
|
TelemetryEvent["EmailTranscriptSent"] = "EmailTranscriptSent";
|
|
117
119
|
TelemetryEvent["EmailTranscriptFailed"] = "EmailTranscriptFailed";
|
|
120
|
+
TelemetryEvent["ErrorUIPaneLoaded"] = "ErrorUIPaneLoaded";
|
|
118
121
|
TelemetryEvent["DownloadTranscriptFailed"] = "DownloadTranscriptFailed";
|
|
119
122
|
TelemetryEvent["StartChatFailed"] = "StartChatFailed";
|
|
120
123
|
TelemetryEvent["IC3ThreadUpdateEventReceived"] = "IC3ThreadUpdateEventReceived";
|
|
@@ -170,6 +173,8 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
170
173
|
TelemetryEvent["ReconnectChatMinimize"] = "ReconnectChatMinimize";
|
|
171
174
|
TelemetryEvent["MessageSent"] = "MessageSent";
|
|
172
175
|
TelemetryEvent["MessageReceived"] = "MessageReceived";
|
|
176
|
+
TelemetryEvent["SystemMessageReceived"] = "SystemMessageReceived";
|
|
177
|
+
TelemetryEvent["HistoryMessageReceived"] = "HistoryMessageReceived";
|
|
173
178
|
TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
|
|
174
179
|
TelemetryEvent["NetworkDisconnected"] = "NetworkDisconnected";
|
|
175
180
|
TelemetryEvent["NetworkReconnected"] = "NetworkReconnected";
|
|
@@ -72,7 +72,7 @@ const HeaderStateful = props => {
|
|
|
72
72
|
...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
|
|
73
73
|
hideTitle: state.appStates.conversationState === _ConversationState.ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
74
74
|
hideIcon: state.appStates.conversationState === _ConversationState.ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
|
|
75
|
-
hideCloseButton: state.appStates.conversationState === _ConversationState.ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === _ConversationState.ConversationState.Prechat || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
|
|
75
|
+
hideCloseButton: state.appStates.conversationState === _ConversationState.ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading || state.appStates.conversationState === _ConversationState.ConversationState.Prechat || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
|
|
76
76
|
};
|
|
77
77
|
const outOfOfficeControlProps = {
|
|
78
78
|
id: "oc-lcw-header",
|
|
@@ -427,7 +427,8 @@ const dummyDefaultProps = {
|
|
|
427
427
|
alignItems: "center",
|
|
428
428
|
margin: "0px 14px 0px 14px",
|
|
429
429
|
textOverflow: "ellipsis !important",
|
|
430
|
-
width: "
|
|
430
|
+
width: "90px",
|
|
431
|
+
whiteSpace: "nowrap",
|
|
431
432
|
cursor: "pointer"
|
|
432
433
|
},
|
|
433
434
|
classNames: {
|
|
@@ -584,6 +585,7 @@ const dummyDefaultProps = {
|
|
|
584
585
|
hideCallingContainer: false,
|
|
585
586
|
hideChatButton: false,
|
|
586
587
|
hideConfirmationPane: false,
|
|
588
|
+
hideErrorUIPane: false,
|
|
587
589
|
hideFooter: false,
|
|
588
590
|
hideHeader: false,
|
|
589
591
|
hideLoadingPane: false,
|
|
@@ -1031,7 +1033,8 @@ const dummyDefaultProps = {
|
|
|
1031
1033
|
margin: "0px 0px 20px 0px",
|
|
1032
1034
|
display: "flex",
|
|
1033
1035
|
order: 1,
|
|
1034
|
-
alignSelf: "auto"
|
|
1036
|
+
alignSelf: "auto",
|
|
1037
|
+
overflow: "visible"
|
|
1035
1038
|
},
|
|
1036
1039
|
iconImageProps: {
|
|
1037
1040
|
src: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxnIG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AwIDAgMSAwIDAgMCAwLjE2IDAiLz4NCjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW4yPSJlZmZlY3QyX2lubmVyU2hhZG93IiByZXN1bHQ9ImVmZmVjdDNfaW5uZXJTaGFkb3ciLz4NCjwvZmlsdGVyPg0KPGxpbmVhckdyYWRpZW50IGlkPSJwYWludDBfbGluZWFyIiB4MT0iLTAuMzk1MDAxIiB5MT0iMjMuMTI4MiIgeDI9IjIwLjEwNTgiIHkyPSIzNy44NDc0IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+DQo8c3RvcCBzdG9wLWNvbG9yPSIjRUZFRkVGIi8+DQo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IndoaXRlIi8+DQo8L2xpbmVhckdyYWRpZW50Pg0KPC9kZWZzPg0KPC9zdmc+DQo=",
|
|
@@ -1212,7 +1215,7 @@ const dummyDefaultProps = {
|
|
|
1212
1215
|
generalStyleProps: {
|
|
1213
1216
|
borderStyle: "solid",
|
|
1214
1217
|
borderRadius: "4px",
|
|
1215
|
-
borderWidth: "
|
|
1218
|
+
borderWidth: "0px",
|
|
1216
1219
|
backgroundColor: "#FFFFFF",
|
|
1217
1220
|
borderColor: "#F1F1F1",
|
|
1218
1221
|
overflowY: "auto",
|
|
@@ -17,15 +17,15 @@ var _utils = require("../../../common/utils");
|
|
|
17
17
|
var _authHelper = require("./authHelper");
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
19
|
const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
|
|
20
|
-
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
|
|
21
|
-
const isPostChatEnabled = (_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveyenable;
|
|
22
|
-
const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode;
|
|
20
|
+
var _props$chatConfig, _props$chatConfig$Liv, _state$domainStates$l, _state$domainStates$l2, _props$chatConfig2, _props$chatConfig2$Li, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
|
|
21
|
+
const isPostChatEnabled = ((_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_postconversationsurveyenable) ?? ((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveyenable);
|
|
22
|
+
const postChatSurveyMode = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_postconversationsurveymode) ?? ((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode);
|
|
23
23
|
|
|
24
24
|
//Unable to end chat if token has expired
|
|
25
25
|
if (props.getAuthToken) {
|
|
26
26
|
const authClientFunction = (0, _authHelper.getAuthClientFunction)(props.chatConfig);
|
|
27
27
|
if (props.getAuthToken && authClientFunction) {
|
|
28
|
-
// set auth token to chat sdk before
|
|
28
|
+
// set auth token to chat sdk before end chat
|
|
29
29
|
const authSuccess = await (0, _authHelper.handleAuthentication)(chatSDK, props.chatConfig, props.getAuthToken);
|
|
30
30
|
if (!authSuccess) {
|
|
31
31
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
@@ -61,15 +61,20 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
61
61
|
chatSDK.requestId = chatSession.requestId;
|
|
62
62
|
}
|
|
63
63
|
if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
// Only start embedded Postchat workflow if postchat context is set successfully else close chat
|
|
65
|
+
if (state.domainStates.postChatContext) {
|
|
66
|
+
dispatch({
|
|
67
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
68
|
+
payload: _ConversationState.ConversationState.PostchatLoading
|
|
69
|
+
});
|
|
70
|
+
await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
|
|
71
|
+
const loadPostChatEvent = {
|
|
72
|
+
eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
|
|
73
|
+
};
|
|
74
|
+
_omnichannelChatComponents.BroadcastService.postMessage(loadPostChatEvent);
|
|
75
|
+
} else {
|
|
76
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, true, false, true);
|
|
77
|
+
}
|
|
73
78
|
} else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
|
|
74
79
|
var _props$webChatContain, _props$webChatContain2;
|
|
75
80
|
dispatch({
|
|
@@ -156,10 +161,6 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
156
161
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
|
|
157
162
|
payload: null
|
|
158
163
|
});
|
|
159
|
-
dispatch({
|
|
160
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
161
|
-
payload: 0
|
|
162
|
-
});
|
|
163
164
|
dispatch({
|
|
164
165
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
165
166
|
payload: {
|
|
@@ -182,6 +183,11 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
182
183
|
exception: `Failed to endChat: ${error}`
|
|
183
184
|
}
|
|
184
185
|
});
|
|
186
|
+
} finally {
|
|
187
|
+
dispatch({
|
|
188
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
189
|
+
payload: 0
|
|
190
|
+
});
|
|
185
191
|
}
|
|
186
192
|
}
|
|
187
193
|
};
|
|
@@ -39,7 +39,7 @@ var _Constants = require("../../../common/Constants");
|
|
|
39
39
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
40
40
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
41
|
const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
|
|
42
|
-
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
|
|
42
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$chatConfig, _props$chatConfig$Liv, _state$domainStates$l, _state$domainStates$l2, _props$chatConfig2, _props$chatConfig2$Li, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
|
|
43
43
|
const localizedTexts = {
|
|
44
44
|
..._defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts,
|
|
45
45
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
|
|
@@ -47,8 +47,8 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
47
47
|
const disableNewLineMarkdownSupport = ((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.disableNewLineMarkdownSupport) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.disableNewLineMarkdownSupport;
|
|
48
48
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
49
49
|
const markdown = (0, _createMarkdown.createMarkdown)(((_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.disableMarkdownMessageFormatting) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.disableMarkdownMessageFormatting, disableNewLineMarkdownSupport);
|
|
50
|
-
const isPostChatEnabled = (_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveyenable;
|
|
51
|
-
const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode;
|
|
50
|
+
const isPostChatEnabled = ((_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_postconversationsurveyenable) ?? ((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveyenable);
|
|
51
|
+
const postChatSurveyMode = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_postconversationsurveymode) ?? ((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode);
|
|
52
52
|
|
|
53
53
|
// Initialize Web Chat's redux store
|
|
54
54
|
let webChatStore = _WebChatStoreLoader.WebChatStoreLoader.store;
|
|
@@ -70,16 +70,28 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
70
70
|
}
|
|
71
71
|
if (isPostChatEnabled === "true") {
|
|
72
72
|
if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
// Only start embedded Postchat workflow if postchat context is set successfully else close chat
|
|
74
|
+
if (state.domainStates.postChatContext) {
|
|
75
|
+
_WebChatStoreLoader.WebChatStoreLoader.store = null;
|
|
76
|
+
dispatch({
|
|
77
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
78
|
+
payload: _ConversationState.ConversationState.PostchatLoading
|
|
79
|
+
});
|
|
80
|
+
await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
|
|
81
|
+
const loadPostChatEvent = {
|
|
82
|
+
eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
|
|
83
|
+
};
|
|
84
|
+
_omnichannelChatComponents.BroadcastService.postMessage(loadPostChatEvent);
|
|
85
|
+
} else {
|
|
86
|
+
dispatch({
|
|
87
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
88
|
+
payload: _ConversationState.ConversationState.InActive
|
|
89
|
+
});
|
|
90
|
+
dispatch({
|
|
91
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
|
|
92
|
+
payload: true
|
|
93
|
+
});
|
|
94
|
+
}
|
|
83
95
|
} else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
|
|
84
96
|
dispatch({
|
|
85
97
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
@@ -60,14 +60,14 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
|
|
|
60
60
|
const chatReconnectOptionalParams = {
|
|
61
61
|
reconnectId: (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId
|
|
62
62
|
};
|
|
63
|
+
// Get auth token for getting chat reconnect context
|
|
63
64
|
if (isAuthenticatedChat) {
|
|
64
|
-
// Get auth token for for getting chat reconnect context
|
|
65
65
|
await (0, _authHelper.handleAuthentication)(chatSDK, chatConfig, props.getAuthToken);
|
|
66
66
|
}
|
|
67
67
|
const reconnectChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext(chatReconnectOptionalParams));
|
|
68
68
|
if (isAuthenticatedChat) {
|
|
69
69
|
// remove auth token after reconnectId is fetched
|
|
70
|
-
//
|
|
70
|
+
// AuthToken will be reset later at start chat
|
|
71
71
|
(0, _authHelper.removeAuthTokenProvider)(chatSDK);
|
|
72
72
|
}
|
|
73
73
|
return reconnectChatContext;
|
|
@@ -101,7 +101,7 @@ const setReconnectIdAndStartChat = async (isAuthenticatedChat, chatSDK, props, d
|
|
|
101
101
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
102
102
|
payload: _ConversationState.ConversationState.Loading
|
|
103
103
|
});
|
|
104
|
-
await initStartChat(chatSDK,
|
|
104
|
+
await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
|
|
105
105
|
};
|
|
106
106
|
const redirectPage = (redirectURL, redirectInSameWindow) => {
|
|
107
107
|
const redirectPageRequest = {
|
|
@@ -87,12 +87,17 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
87
87
|
const optionalParams = {
|
|
88
88
|
isProactiveChat
|
|
89
89
|
};
|
|
90
|
-
await initStartChat(chatSDK,
|
|
90
|
+
await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
94
|
exports.setPreChatAndInitiateChat = setPreChatAndInitiateChat;
|
|
95
|
-
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;
|
|
96
101
|
try {
|
|
97
102
|
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
98
103
|
//Start widget load timer
|
|
@@ -106,10 +111,13 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
106
111
|
// set auth token to chat sdk before start chat
|
|
107
112
|
const authSuccess = await (0, _authHelper.handleAuthentication)(chatSDK, chatConfig, getAuthToken);
|
|
108
113
|
if (!authSuccess) {
|
|
114
|
+
dispatch({
|
|
115
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
116
|
+
payload: _ConversationState.ConversationState.Closed
|
|
117
|
+
});
|
|
109
118
|
return;
|
|
110
119
|
}
|
|
111
120
|
}
|
|
112
|
-
let isStartChatSuccessful = false;
|
|
113
121
|
|
|
114
122
|
//Check if chat retrieved from cache
|
|
115
123
|
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
@@ -142,12 +150,6 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
142
150
|
}
|
|
143
151
|
});
|
|
144
152
|
isStartChatSuccessful = false;
|
|
145
|
-
// Resetting the widget state to Closed, for recent introduction of OC rate limiting(429 Error)
|
|
146
|
-
// TODO : How to diplay a proper UI message to customer to try after sometime at this point - cool down scenario
|
|
147
|
-
dispatch({
|
|
148
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
149
|
-
payload: _ConversationState.ConversationState.Closed
|
|
150
|
-
});
|
|
151
153
|
return;
|
|
152
154
|
}
|
|
153
155
|
|
|
@@ -176,12 +178,6 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
176
178
|
payload: liveChatContext
|
|
177
179
|
});
|
|
178
180
|
|
|
179
|
-
// Set post chat context in state, no survey load
|
|
180
|
-
(0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
|
|
181
|
-
|
|
182
|
-
// Updating chat session detail for telemetry
|
|
183
|
-
await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch);
|
|
184
|
-
|
|
185
181
|
// Set app state to Active
|
|
186
182
|
if (isStartChatSuccessful) {
|
|
187
183
|
_ActivityStreamHandler.ActivityStreamHandler.uncork();
|
|
@@ -200,6 +196,12 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
200
196
|
Description: "Widget load complete",
|
|
201
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
|
|
202
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);
|
|
203
205
|
} catch (ex) {
|
|
204
206
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
205
207
|
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
@@ -220,16 +222,28 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
220
222
|
});
|
|
221
223
|
return;
|
|
222
224
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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
|
+
}
|
|
228
236
|
// Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
|
|
229
237
|
dispatch({
|
|
230
238
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
231
239
|
payload: _ConversationState.ConversationState.Loading
|
|
232
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
|
+
}
|
|
233
247
|
} finally {
|
|
234
248
|
optionalParams = {};
|
|
235
249
|
widgetInstanceId = "";
|
|
@@ -238,16 +252,27 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
238
252
|
|
|
239
253
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
240
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
|
|
241
266
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
242
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$
|
|
267
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps3, _persistedState$domai6;
|
|
243
268
|
// By pass this function in case of popout chat
|
|
244
269
|
if (state.appStates.hideStartChatButton === true) {
|
|
245
270
|
return false;
|
|
246
271
|
}
|
|
247
|
-
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) ?? "");
|
|
248
273
|
|
|
249
274
|
//Connect to only active chat session
|
|
250
|
-
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)) {
|
|
251
276
|
var _persistedState$domai7;
|
|
252
277
|
dispatch({
|
|
253
278
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
@@ -256,7 +281,7 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
256
281
|
const optionalParams = {
|
|
257
282
|
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
|
|
258
283
|
};
|
|
259
|
-
await initStartChat(chatSDK,
|
|
284
|
+
await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
|
|
260
285
|
return true;
|
|
261
286
|
} else {
|
|
262
287
|
return false;
|
|
@@ -286,38 +311,11 @@ const setCustomContextParams = chatSDK => {
|
|
|
286
311
|
}
|
|
287
312
|
};
|
|
288
313
|
|
|
289
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
290
|
-
const handleAuthenticationIfEnabled = async (chatSDK, props) => {
|
|
291
|
-
//For auth chat
|
|
292
|
-
if (props.getAuthToken) {
|
|
293
|
-
const authClientFunction = (0, _authHelper.getAuthClientFunction)(props.chatConfig);
|
|
294
|
-
if (authClientFunction) {
|
|
295
|
-
// set auth token to chat sdk before start chat
|
|
296
|
-
const authSuccess = await (0, _authHelper.handleAuthentication)(chatSDK, props.chatConfig, props.getAuthToken);
|
|
297
|
-
if (!authSuccess) {
|
|
298
|
-
return false;
|
|
299
|
-
}
|
|
300
|
-
return true;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return true;
|
|
304
|
-
};
|
|
305
|
-
|
|
306
314
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
307
315
|
const checkIfConversationStillValid = async (chatSDK, props, requestId, dispatch) => {
|
|
308
316
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
309
317
|
let conversationDetails = undefined;
|
|
310
318
|
|
|
311
|
-
// Show Loading screen during auth check and start chat calls
|
|
312
|
-
dispatch({
|
|
313
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
314
|
-
payload: _ConversationState.ConversationState.Loading
|
|
315
|
-
});
|
|
316
|
-
const authSucceed = await handleAuthenticationIfEnabled(chatSDK, props);
|
|
317
|
-
if (!authSucceed) {
|
|
318
|
-
return false;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
319
|
//Preserve old requestId
|
|
322
320
|
const oldRequestId = chatSDK.requestId;
|
|
323
321
|
try {
|
|
@@ -328,6 +326,10 @@ const checkIfConversationStillValid = async (chatSDK, props, requestId, dispatch
|
|
|
328
326
|
return false;
|
|
329
327
|
}
|
|
330
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
|
+
});
|
|
331
333
|
chatSDK.requestId = oldRequestId;
|
|
332
334
|
return false;
|
|
333
335
|
}
|