@microsoft/omnichannel-chat-widget 1.6.2 → 1.6.3-main.24dce14
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/telemetry/TelemetryConstants.js +1 -0
- package/lib/cjs/common/utils.js +15 -6
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +29 -24
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +3 -6
- package/lib/cjs/components/livechatwidget/common/authHelper.js +4 -1
- package/lib/cjs/components/livechatwidget/common/endChat.js +9 -30
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +13 -3
- package/lib/cjs/components/livechatwidget/common/startChat.js +35 -19
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +5 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +53 -53
- package/lib/cjs/components/webchatcontainerstateful/common/utils/isMaskingFromCustomer.js +4 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +10 -0
- package/lib/cjs/contexts/createReducer.js +653 -345
- package/lib/esm/common/telemetry/TelemetryConstants.js +1 -0
- package/lib/esm/common/utils.js +12 -4
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +30 -25
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +3 -6
- package/lib/esm/components/livechatwidget/common/authHelper.js +4 -1
- package/lib/esm/components/livechatwidget/common/endChat.js +10 -31
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +15 -4
- package/lib/esm/components/livechatwidget/common/startChat.js +35 -19
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +5 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +53 -53
- package/lib/esm/components/webchatcontainerstateful/common/utils/isMaskingFromCustomer.js +4 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +10 -0
- package/lib/esm/contexts/createReducer.js +650 -343
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -1
- package/lib/types/common/utils.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +1 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/lib/types/contexts/createReducer.d.ts +1 -0
- package/package.json +6 -4
|
@@ -59,6 +59,7 @@ export let BroadcastEvent;
|
|
|
59
59
|
BroadcastEvent["UpdateSessionDataForTelemetry"] = "UpdateSessionDataForTelemetry";
|
|
60
60
|
BroadcastEvent["UpdateConversationDataForTelemetry"] = "UpdateConversationDataForTelemetry";
|
|
61
61
|
BroadcastEvent["ContactIdNotFound"] = "ContactIdNotFound";
|
|
62
|
+
BroadcastEvent["SyncMinimize"] = "SyncMinimize";
|
|
62
63
|
})(BroadcastEvent || (BroadcastEvent = {}));
|
|
63
64
|
export let TelemetryEvent;
|
|
64
65
|
(function (TelemetryEvent) {
|
package/lib/esm/common/utils.js
CHANGED
|
@@ -351,15 +351,20 @@ export const debounceLeading = function (fn) {
|
|
|
351
351
|
};
|
|
352
352
|
|
|
353
353
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
354
|
-
export const getConversationDetailsCall = async chatSDK
|
|
355
|
-
|
|
356
|
-
let conversationDetails = undefined;
|
|
354
|
+
export const getConversationDetailsCall = async function (chatSDK) {
|
|
355
|
+
let liveChatContext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
356
|
+
let conversationDetails = undefined; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
357
|
+
const optionalParams = {}; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
358
|
+
|
|
359
|
+
if (liveChatContext !== null && liveChatContext !== void 0 && liveChatContext.requestId && liveChatContext !== null && liveChatContext !== void 0 && liveChatContext.chatToken) {
|
|
360
|
+
optionalParams.liveChatContext = liveChatContext;
|
|
361
|
+
}
|
|
357
362
|
try {
|
|
358
363
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
359
364
|
Event: TelemetryEvent.GetConversationDetailsCallStarted,
|
|
360
365
|
Description: "Conversation details call started"
|
|
361
366
|
});
|
|
362
|
-
conversationDetails = await chatSDK.getConversationDetails();
|
|
367
|
+
conversationDetails = await chatSDK.getConversationDetails(optionalParams);
|
|
363
368
|
} catch (error) {
|
|
364
369
|
checkContactIdError(error);
|
|
365
370
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
@@ -413,4 +418,7 @@ export const formatTemplateString = (templateMessage, values) => {
|
|
|
413
418
|
return templateMessage.replace(/{(\d+)}/g, (match, index) => {
|
|
414
419
|
return typeof values[index] !== "undefined" ? values[index] : match;
|
|
415
420
|
});
|
|
421
|
+
};
|
|
422
|
+
export const parseLowerCaseString = property => {
|
|
423
|
+
return String(property).toLowerCase();
|
|
416
424
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
2
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
3
3
|
import { findAllFocusableElement, findParentFocusableElementsWithoutChildContainer, formatTemplateString, preventFocusToMoveOutOfElement, setFocusOnElement, setFocusOnSendBox, setTabIndices } from "../../common/utils";
|
|
4
4
|
import { DimLayer } from "../dimlayer/DimLayer";
|
|
5
5
|
import { InputValidationPane } from "@microsoft/omnichannel-chat-components";
|
|
@@ -36,33 +36,38 @@ export const EmailTranscriptPaneStateful = props => {
|
|
|
36
36
|
});
|
|
37
37
|
setTabIndices(elements, initialTabIndexMap, true);
|
|
38
38
|
};
|
|
39
|
+
const onSend = useCallback(async email => {
|
|
40
|
+
var _state$domainStates;
|
|
41
|
+
const liveChatContext = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext;
|
|
42
|
+
closeEmailTranscriptPane();
|
|
43
|
+
const chatTranscriptBody = {
|
|
44
|
+
emailAddress: email,
|
|
45
|
+
attachmentMessage: (props === null || props === void 0 ? void 0 : props.attachmentMessage) ?? "The following attachment was uploaded during the conversation:"
|
|
46
|
+
};
|
|
47
|
+
try {
|
|
48
|
+
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.emailLiveChatTranscript(chatTranscriptBody, {
|
|
49
|
+
liveChatContext
|
|
50
|
+
}));
|
|
51
|
+
NotificationHandler.notifySuccess(NotificationScenarios.EmailAddressSaved, defaultMiddlewareLocalizedTexts === null || defaultMiddlewareLocalizedTexts === void 0 ? void 0 : defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS);
|
|
52
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
53
|
+
Event: TelemetryEvent.EmailTranscriptSent,
|
|
54
|
+
Description: "Transcript sent to email successfully."
|
|
55
|
+
});
|
|
56
|
+
} catch (ex) {
|
|
57
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
58
|
+
Event: TelemetryEvent.EmailTranscriptFailed,
|
|
59
|
+
ExceptionDetails: {
|
|
60
|
+
exception: ex
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
const message = formatTemplateString(defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR, [email]);
|
|
64
|
+
NotificationHandler.notifyError(NotificationScenarios.EmailTranscriptError, (props === null || props === void 0 ? void 0 : props.bannerMessageOnError) ?? message);
|
|
65
|
+
}
|
|
66
|
+
}, [props.attachmentMessage, props.bannerMessageOnError, chatSDK, state.domainStates.liveChatContext]);
|
|
39
67
|
const controlProps = {
|
|
40
68
|
id: "oclcw-emailTranscriptDialogContainer",
|
|
41
69
|
dir: state.domainStates.globalDir,
|
|
42
|
-
onSend
|
|
43
|
-
closeEmailTranscriptPane();
|
|
44
|
-
const chatTranscriptBody = {
|
|
45
|
-
emailAddress: email,
|
|
46
|
-
attachmentMessage: (props === null || props === void 0 ? void 0 : props.attachmentMessage) ?? "The following attachment was uploaded during the conversation:"
|
|
47
|
-
};
|
|
48
|
-
try {
|
|
49
|
-
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.emailLiveChatTranscript(chatTranscriptBody));
|
|
50
|
-
NotificationHandler.notifySuccess(NotificationScenarios.EmailAddressSaved, defaultMiddlewareLocalizedTexts === null || defaultMiddlewareLocalizedTexts === void 0 ? void 0 : defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS);
|
|
51
|
-
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
52
|
-
Event: TelemetryEvent.EmailTranscriptSent,
|
|
53
|
-
Description: "Transcript sent to email successfully."
|
|
54
|
-
});
|
|
55
|
-
} catch (ex) {
|
|
56
|
-
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
57
|
-
Event: TelemetryEvent.EmailTranscriptFailed,
|
|
58
|
-
ExceptionDetails: {
|
|
59
|
-
exception: ex
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
const message = formatTemplateString(defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR, [email]);
|
|
63
|
-
NotificationHandler.notifyError(NotificationScenarios.EmailTranscriptError, (props === null || props === void 0 ? void 0 : props.bannerMessageOnError) ?? message);
|
|
64
|
-
}
|
|
65
|
-
},
|
|
70
|
+
onSend,
|
|
66
71
|
onCancel: () => {
|
|
67
72
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
68
73
|
Event: TelemetryEvent.EmailTranscriptCancelButtonClicked,
|
package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -157,12 +157,9 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
157
157
|
|
|
158
158
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
159
159
|
export const downloadTranscript = async (chatSDK, downloadTranscriptProps, state) => {
|
|
160
|
-
var _state$domainStates
|
|
161
|
-
// Need to keep existing
|
|
162
|
-
const liveChatContext =
|
|
163
|
-
chatToken: state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.chatToken,
|
|
164
|
-
requestId: state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : (_state$domainStates2$ = _state$domainStates2.chatToken) === null || _state$domainStates2$ === void 0 ? void 0 : _state$domainStates2$.requestId
|
|
165
|
-
};
|
|
160
|
+
var _state$domainStates;
|
|
161
|
+
// Need to keep existing live chat context for scenarios when trnascript is downloaded after endchat
|
|
162
|
+
const liveChatContext = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext;
|
|
166
163
|
let data = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getLiveChatTranscript({
|
|
167
164
|
liveChatContext
|
|
168
165
|
}));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
3
3
|
import { isNullOrEmptyString } from "../../../common/utils";
|
|
4
|
+
import { WidgetLoadCustomErrorString } from "../../../common/Constants";
|
|
4
5
|
const getAuthClientFunction = chatConfig => {
|
|
5
6
|
let authClientFunction = undefined;
|
|
6
7
|
if (chatConfig !== null && chatConfig !== void 0 && chatConfig.LiveChatConfigAuthSettings) {
|
|
@@ -25,10 +26,12 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
|
25
26
|
});
|
|
26
27
|
return true;
|
|
27
28
|
} else {
|
|
29
|
+
// instead of returning false, it's more appropiate to thrown an error to force error handling on the caller side
|
|
30
|
+
// this will help to avoid the error to be ignored and the chat to be started
|
|
28
31
|
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
29
32
|
Event: TelemetryEvent.ReceivedNullOrEmptyToken
|
|
30
33
|
});
|
|
31
|
-
|
|
34
|
+
throw new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
37
|
return false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfirmationState, Constants, ConversationEndEntity, ParticipantType, PrepareEndChatDescriptionConstants } from "../../../common/Constants";
|
|
2
2
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
-
import {
|
|
3
|
+
import { handleAuthentication } from "./authHelper";
|
|
4
4
|
import { getConversationDetailsCall, getWidgetEndChatEventName } from "../../../common/utils";
|
|
5
5
|
import { getPostChatContext, initiatePostChat } from "./renderSurveyHelpers";
|
|
6
6
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
@@ -113,7 +113,7 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
|
|
|
113
113
|
Event: TelemetryEvent.EndChatSDKCall
|
|
114
114
|
});
|
|
115
115
|
//Get auth token again if chat continued for longer time, otherwise gets 401 error
|
|
116
|
-
await
|
|
116
|
+
await handleAuthentication(chatSDK, props.chatConfig, props.getAuthToken);
|
|
117
117
|
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
|
|
118
118
|
} catch (ex) {
|
|
119
119
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
@@ -192,10 +192,6 @@ export const callingStateCleanUp = dispatch => {
|
|
|
192
192
|
};
|
|
193
193
|
export const endChatStateCleanUp = dispatch => {
|
|
194
194
|
// Need to clear these states immediately when chat ended from OC.
|
|
195
|
-
dispatch({
|
|
196
|
-
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
197
|
-
payload: undefined
|
|
198
|
-
});
|
|
199
195
|
dispatch({
|
|
200
196
|
type: LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
201
197
|
payload: undefined
|
|
@@ -239,6 +235,12 @@ export const closeChatStateCleanUp = dispatch => {
|
|
|
239
235
|
proactiveChatInNewWindow: false
|
|
240
236
|
}
|
|
241
237
|
});
|
|
238
|
+
|
|
239
|
+
// Clear live chat context only if chat widget is fully closed to support transcript calls after sessionclose is called
|
|
240
|
+
dispatch({
|
|
241
|
+
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
242
|
+
payload: undefined
|
|
243
|
+
});
|
|
242
244
|
};
|
|
243
245
|
|
|
244
246
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -296,27 +298,6 @@ const closeChatWidget = (dispatch, props, state) => {
|
|
|
296
298
|
});
|
|
297
299
|
};
|
|
298
300
|
|
|
299
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
300
|
-
const handleAuthenticationIfEnabled = async (props, chatSDK) => {
|
|
301
|
-
//Unable to end chat if token has expired
|
|
302
|
-
if (props.getAuthToken) {
|
|
303
|
-
const authClientFunction = getAuthClientFunction(props.chatConfig);
|
|
304
|
-
if (props.getAuthToken && authClientFunction) {
|
|
305
|
-
// set auth token to chat sdk before end chat
|
|
306
|
-
const authSuccess = await handleAuthentication(chatSDK, props.chatConfig, props.getAuthToken);
|
|
307
|
-
if (!authSuccess) {
|
|
308
|
-
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
309
|
-
Event: TelemetryEvent.GetAuthTokenFailed,
|
|
310
|
-
ExceptionDetails: {
|
|
311
|
-
exception: "Unable to get auth token during end chat"
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
throw new Error("handleAuthenticationIfEnabled:Failed to get authentication token");
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
|
|
320
301
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
321
302
|
const chatTokenCleanUp = async dispatch => {
|
|
322
303
|
//Just do cleanup here
|
|
@@ -324,10 +305,8 @@ const chatTokenCleanUp = async dispatch => {
|
|
|
324
305
|
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
325
306
|
payload: undefined
|
|
326
307
|
});
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
payload: undefined
|
|
330
|
-
});
|
|
308
|
+
|
|
309
|
+
// Need to keep liveChatContext until chat is fully closed to for transcript download/email
|
|
331
310
|
};
|
|
332
311
|
|
|
333
312
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -3,10 +3,12 @@ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/teleme
|
|
|
3
3
|
import { checkContactIdError, isNullOrEmptyString, isNullOrUndefined } from "../../../common/utils";
|
|
4
4
|
import { handleAuthentication, removeAuthTokenProvider } from "./authHelper";
|
|
5
5
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
6
|
-
import { ConversationMode } from "../../../common/Constants";
|
|
6
|
+
import { ConversationMode, WidgetLoadCustomErrorString } from "../../../common/Constants";
|
|
7
7
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
8
8
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
9
9
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
10
|
+
import { handleStartChatError } from "./startChatErrorHandler";
|
|
11
|
+
|
|
10
12
|
// Return value: should start normal chat flow when reconnect is enabled
|
|
11
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
14
|
const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initStartChat, state) => {
|
|
@@ -15,7 +17,7 @@ const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initSta
|
|
|
15
17
|
const isAuthenticatedChat = (_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;
|
|
16
18
|
|
|
17
19
|
// Get chat reconnect context
|
|
18
|
-
const reconnectChatContext = await getChatReconnectContext(chatSDK, props.chatConfig, props, isAuthenticatedChat);
|
|
20
|
+
const reconnectChatContext = await getChatReconnectContext(chatSDK, props.chatConfig, props, isAuthenticatedChat, dispatch);
|
|
19
21
|
|
|
20
22
|
// Redirect if enabled
|
|
21
23
|
if (reconnectChatContext !== null && reconnectChatContext !== void 0 && reconnectChatContext.redirectURL) {
|
|
@@ -50,7 +52,7 @@ const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initSta
|
|
|
50
52
|
};
|
|
51
53
|
|
|
52
54
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
-
const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticatedChat) => {
|
|
55
|
+
const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticatedChat, dispatch) => {
|
|
54
56
|
try {
|
|
55
57
|
var _props$reconnectChatP4;
|
|
56
58
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
@@ -62,6 +64,7 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
|
|
|
62
64
|
};
|
|
63
65
|
// Get auth token for getting chat reconnect context
|
|
64
66
|
if (isAuthenticatedChat) {
|
|
67
|
+
// handle authentication will throw error if auth token is not available, so no need to check for response
|
|
65
68
|
await handleAuthentication(chatSDK, chatConfig, props.getAuthToken);
|
|
66
69
|
}
|
|
67
70
|
const reconnectChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext(chatReconnectOptionalParams));
|
|
@@ -71,7 +74,9 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
|
|
|
71
74
|
removeAuthTokenProvider(chatSDK);
|
|
72
75
|
}
|
|
73
76
|
return reconnectChatContext;
|
|
74
|
-
}
|
|
77
|
+
}
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
+
catch (error) {
|
|
75
80
|
checkContactIdError(error);
|
|
76
81
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
77
82
|
Event: TelemetryEvent.GetChatReconnectContextSDKCallFailed,
|
|
@@ -79,6 +84,12 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
|
|
|
79
84
|
exception: error
|
|
80
85
|
}
|
|
81
86
|
});
|
|
87
|
+
|
|
88
|
+
// when auth token is not available, propagate the error to stop the execution and ensure error pane is loaded
|
|
89
|
+
if ((error === null || error === void 0 ? void 0 : error.message) == WidgetLoadCustomErrorString.AuthenticationFailedErrorString) {
|
|
90
|
+
handleStartChatError(dispatch, chatSDK, props, new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString), false);
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
82
93
|
}
|
|
83
94
|
};
|
|
84
95
|
|
|
@@ -27,7 +27,6 @@ let popoutWidgetInstanceId;
|
|
|
27
27
|
const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
28
28
|
optionalParams = {}; //Resetting to ensure no stale values
|
|
29
29
|
widgetInstanceId = getWidgetCacheIdfromProps(props);
|
|
30
|
-
|
|
31
30
|
// reconnect > chat from cache
|
|
32
31
|
if (isReconnectEnabled(props.chatConfig) === true && !isPersistentEnabled(props.chatConfig)) {
|
|
33
32
|
const shouldStartChatNormally = await handleChatReconnect(chatSDK, props, dispatch, setAdapter, initStartChat, state);
|
|
@@ -77,6 +76,7 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
77
76
|
});
|
|
78
77
|
return;
|
|
79
78
|
} else {
|
|
79
|
+
var _state$appStates;
|
|
80
80
|
dispatch({
|
|
81
81
|
type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
82
82
|
payload: preChatSurveyResponse
|
|
@@ -85,6 +85,24 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
85
85
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
86
86
|
payload: ConversationState.Prechat
|
|
87
87
|
});
|
|
88
|
+
|
|
89
|
+
// If minimized, maximize the chat, if the state is missing, consider it as minimized
|
|
90
|
+
if ((state === null || state === void 0 ? void 0 : state.appStates.isMinimized) == undefined || (state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.isMinimized) === true) {
|
|
91
|
+
var _state$domainStates2, _state$domainStates2$, _state$domainStates3, _state$domainStates3$;
|
|
92
|
+
dispatch({
|
|
93
|
+
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
94
|
+
payload: false
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// this event will notify the upper layer to maximize the widget, an event missing during multi-tab scenario.
|
|
98
|
+
BroadcastService.postMessage({
|
|
99
|
+
eventName: BroadcastEvent.MaximizeChat,
|
|
100
|
+
payload: {
|
|
101
|
+
height: state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : (_state$domainStates2$ = _state$domainStates2.widgetSize) === null || _state$domainStates2$ === void 0 ? void 0 : _state$domainStates2$.height,
|
|
102
|
+
width: state === null || state === void 0 ? void 0 : (_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : (_state$domainStates3$ = _state$domainStates3.widgetSize) === null || _state$domainStates3$ === void 0 ? void 0 : _state$domainStates3$.width
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
88
106
|
return;
|
|
89
107
|
}
|
|
90
108
|
}
|
|
@@ -110,9 +128,9 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
110
128
|
chatSDKStateCleanUp(chatSDK);
|
|
111
129
|
}
|
|
112
130
|
try {
|
|
113
|
-
var _state$
|
|
131
|
+
var _state$appStates2, _newAdapter$activity$;
|
|
114
132
|
// Clear disconnect state on start chat
|
|
115
|
-
(state === null || state === void 0 ? void 0 : (_state$
|
|
133
|
+
(state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.chatDisconnectEventReceived) && dispatch({
|
|
116
134
|
type: LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
|
|
117
135
|
payload: false
|
|
118
136
|
});
|
|
@@ -207,7 +225,6 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
207
225
|
payload: liveChatContext
|
|
208
226
|
});
|
|
209
227
|
logWidgetLoadComplete();
|
|
210
|
-
|
|
211
228
|
// Set post chat context in state
|
|
212
229
|
// Commenting this for now as post chat context is fetched during end chat
|
|
213
230
|
await setPostChatContextAndLoadSurvey(chatSDK, dispatch);
|
|
@@ -224,9 +241,9 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
224
241
|
|
|
225
242
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
226
243
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
227
|
-
var _state$
|
|
244
|
+
var _state$appStates3, _persistedState$domai6, _persistedState$appSt;
|
|
228
245
|
// By pass this function in case of popout chat
|
|
229
|
-
if ((state === null || state === void 0 ? void 0 : (_state$
|
|
246
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates3 = state.appStates) === null || _state$appStates3 === void 0 ? void 0 : _state$appStates3.hideStartChatButton) === true) {
|
|
230
247
|
return false;
|
|
231
248
|
}
|
|
232
249
|
const persistedState = getStateFromCache(getWidgetCacheIdfromProps(props));
|
|
@@ -249,17 +266,17 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
249
266
|
|
|
250
267
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
251
268
|
const setCustomContextParams = async (state, props) => {
|
|
252
|
-
var _props$chatConfig, _props$chatConfig$Liv, _state$
|
|
269
|
+
var _props$chatConfig, _props$chatConfig$Liv, _state$domainStates4, _persistedState$domai8;
|
|
253
270
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
254
271
|
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;
|
|
255
272
|
//Should not set custom context for auth chat
|
|
256
273
|
if (isAuthenticatedChat) {
|
|
257
274
|
return;
|
|
258
275
|
}
|
|
259
|
-
if (state !== null && state !== void 0 && (_state$
|
|
260
|
-
var _state$
|
|
276
|
+
if (state !== null && state !== void 0 && (_state$domainStates4 = state.domainStates) !== null && _state$domainStates4 !== void 0 && _state$domainStates4.customContext) {
|
|
277
|
+
var _state$domainStates5;
|
|
261
278
|
optionalParams = Object.assign({}, optionalParams, {
|
|
262
|
-
customContext: JSON.parse(JSON.stringify(state === null || state === void 0 ? void 0 : (_state$
|
|
279
|
+
customContext: JSON.parse(JSON.stringify(state === null || state === void 0 ? void 0 : (_state$domainStates5 = state.domainStates) === null || _state$domainStates5 === void 0 ? void 0 : _state$domainStates5.customContext))
|
|
263
280
|
});
|
|
264
281
|
return;
|
|
265
282
|
}
|
|
@@ -307,12 +324,14 @@ const canStartPopoutChat = async props => {
|
|
|
307
324
|
|
|
308
325
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
309
326
|
const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
310
|
-
var _state$
|
|
311
|
-
const requestIdFromCache = (_state$
|
|
327
|
+
var _state$domainStates6, _state$domainStates6$, _state$domainStates7;
|
|
328
|
+
const requestIdFromCache = (_state$domainStates6 = state.domainStates) === null || _state$domainStates6 === void 0 ? void 0 : (_state$domainStates6$ = _state$domainStates6.liveChatContext) === null || _state$domainStates6$ === void 0 ? void 0 : _state$domainStates6$.requestId;
|
|
329
|
+
const liveChatContext = state === null || state === void 0 ? void 0 : (_state$domainStates7 = state.domainStates) === null || _state$domainStates7 === void 0 ? void 0 : _state$domainStates7.liveChatContext;
|
|
330
|
+
|
|
312
331
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
313
332
|
let conversationDetails = undefined;
|
|
314
333
|
|
|
315
|
-
//Preserve current requestId
|
|
334
|
+
// Preserve current requestId
|
|
316
335
|
const currentRequestId = chatSDK.requestId ?? "";
|
|
317
336
|
dispatch({
|
|
318
337
|
type: LiveChatWidgetActionType.SET_INITIAL_CHAT_SDK_REQUEST_ID,
|
|
@@ -320,9 +339,8 @@ const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
|
320
339
|
});
|
|
321
340
|
try {
|
|
322
341
|
chatSDK.requestId = requestIdFromCache;
|
|
323
|
-
conversationDetails = await getConversationDetailsCall(chatSDK);
|
|
342
|
+
conversationDetails = await getConversationDetailsCall(chatSDK, liveChatContext);
|
|
324
343
|
if (Object.keys(conversationDetails).length === 0) {
|
|
325
|
-
chatSDK.requestId = currentRequestId;
|
|
326
344
|
return false;
|
|
327
345
|
}
|
|
328
346
|
if (conversationDetails.state === LiveWorkItemState.Closed || conversationDetails.state === LiveWorkItemState.WrapUp) {
|
|
@@ -330,18 +348,16 @@ const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
|
330
348
|
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
331
349
|
payload: undefined
|
|
332
350
|
});
|
|
333
|
-
chatSDK.requestId = currentRequestId;
|
|
334
351
|
return false;
|
|
335
352
|
}
|
|
336
353
|
return true;
|
|
337
|
-
} catch (
|
|
354
|
+
} catch (error) {
|
|
338
355
|
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
339
356
|
Event: TelemetryEvent.GetConversationDetailsException,
|
|
340
357
|
ExceptionDetails: {
|
|
341
|
-
exception: `Conversation is not valid: ${
|
|
358
|
+
exception: `Conversation is not valid: ${error}`
|
|
342
359
|
}
|
|
343
360
|
});
|
|
344
|
-
chatSDK.requestId = currentRequestId;
|
|
345
361
|
return false;
|
|
346
362
|
}
|
|
347
363
|
};
|
|
@@ -24,6 +24,11 @@ export const handleStartChatError = (dispatch, chatSDK, props, ex, isStartChatSu
|
|
|
24
24
|
type: LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
|
|
25
25
|
payload: StartChatFailureType.AuthSetupError
|
|
26
26
|
});
|
|
27
|
+
// set conversation to error to enforce error UI pane
|
|
28
|
+
dispatch({
|
|
29
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
30
|
+
payload: ConversationState.Error
|
|
31
|
+
});
|
|
27
32
|
logWidgetLoadCompleteWithError(ex);
|
|
28
33
|
}
|
|
29
34
|
if (ex.message === WidgetLoadCustomErrorString.NetworkErrorString) {
|
|
@@ -53,6 +53,7 @@ import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
|
53
53
|
import { defaultAdaptiveCardStyles } from "../../webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles";
|
|
54
54
|
import StartChatErrorPaneStateful from "../../startchaterrorpanestateful/StartChatErrorPaneStateful";
|
|
55
55
|
import { StartChatFailureType } from "../../../contexts/common/StartChatFailureType";
|
|
56
|
+
import { executeReducer } from "../../../contexts/createReducer";
|
|
56
57
|
export const LiveChatWidgetStateful = props => {
|
|
57
58
|
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$webChatContain10, _livechatProps$webCha, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
|
|
58
59
|
const [state, dispatch] = useChatContextStore();
|
|
@@ -117,8 +118,12 @@ export const LiveChatWidgetStateful = props => {
|
|
|
117
118
|
const isReconnectTriggered = async () => {
|
|
118
119
|
if (isReconnectEnabled(props.chatConfig) === true && !isPersistentEnabled(props.chatConfig)) {
|
|
119
120
|
const noValidReconnectId = await handleChatReconnect(chatSDK, props, dispatch, setAdapter, initStartChat, state);
|
|
121
|
+
const inMemoryState = executeReducer(state, {
|
|
122
|
+
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
123
|
+
payload: null
|
|
124
|
+
});
|
|
120
125
|
// If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
|
|
121
|
-
if (!noValidReconnectId && (
|
|
126
|
+
if (!noValidReconnectId && (inMemoryState.appStates.conversationState === ConversationState.Active || inMemoryState.appStates.conversationState === ConversationState.ReconnectChat)) {
|
|
122
127
|
return true;
|
|
123
128
|
}
|
|
124
129
|
}
|
|
@@ -131,9 +136,6 @@ export const LiveChatWidgetStateful = props => {
|
|
|
131
136
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
132
137
|
payload: ConversationState.Loading
|
|
133
138
|
});
|
|
134
|
-
if (localState) {
|
|
135
|
-
localState.appStates.conversationState = ConversationState.Loading;
|
|
136
|
-
}
|
|
137
139
|
|
|
138
140
|
//Check if conversation state is not in wrapup or closed state
|
|
139
141
|
isChatValid = await checkIfConversationStillValid(chatSDK, dispatch, state);
|
|
@@ -150,7 +152,11 @@ export const LiveChatWidgetStateful = props => {
|
|
|
150
152
|
// adding the reconnect logic for the case when customer tries to reconnect from a new browser or InPrivate browser
|
|
151
153
|
const reconnectTriggered = await isReconnectTriggered();
|
|
152
154
|
if (!reconnectTriggered) {
|
|
153
|
-
|
|
155
|
+
const inMemoryState = executeReducer(state, {
|
|
156
|
+
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
157
|
+
payload: null
|
|
158
|
+
});
|
|
159
|
+
await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, undefined, undefined, inMemoryState, props);
|
|
154
160
|
}
|
|
155
161
|
return;
|
|
156
162
|
} else {
|
|
@@ -330,76 +336,70 @@ export const LiveChatWidgetStateful = props => {
|
|
|
330
336
|
}
|
|
331
337
|
});
|
|
332
338
|
|
|
339
|
+
/**
|
|
340
|
+
* This will allow to sync multiple tabs to handle minimize and maximize state,
|
|
341
|
+
* the event is expected to be emitted from scripting layer.
|
|
342
|
+
*/
|
|
343
|
+
BroadcastService.getMessageByEventName(BroadcastEvent.SyncMinimize).subscribe(msg => {
|
|
344
|
+
var _msg$payload4;
|
|
345
|
+
dispatch({
|
|
346
|
+
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
347
|
+
payload: msg === null || msg === void 0 ? void 0 : (_msg$payload4 = msg.payload) === null || _msg$payload4 === void 0 ? void 0 : _msg$payload4.minimized
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
333
351
|
// Start chat from SDK Event
|
|
334
352
|
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(msg => {
|
|
335
|
-
var _msg$
|
|
353
|
+
var _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta, _inMemoryState$appSta2, _inMemoryState$appSta3, _inMemoryState$appSta4;
|
|
336
354
|
// If the startChat event is not initiated by the same tab. Ignore the call
|
|
337
|
-
if (!isNullOrUndefined(msg === null || msg === void 0 ? void 0 : (_msg$
|
|
355
|
+
if (!isNullOrUndefined(msg === null || msg === void 0 ? void 0 : (_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.runtimeId) && (msg === null || msg === void 0 ? void 0 : (_msg$payload6 = msg.payload) === null || _msg$payload6 === void 0 ? void 0 : _msg$payload6.runtimeId) !== TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
338
356
|
return;
|
|
339
357
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
var _msg$payload7, _msg$payload8;
|
|
358
|
+
if (msg !== null && msg !== void 0 && (_msg$payload7 = msg.payload) !== null && _msg$payload7 !== void 0 && _msg$payload7.customContext) {
|
|
359
|
+
var _msg$payload8;
|
|
343
360
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
344
361
|
Event: TelemetryEvent.CustomContextReceived,
|
|
345
362
|
Description: "CustomContext received through startChat event."
|
|
346
363
|
});
|
|
347
364
|
dispatch({
|
|
348
365
|
type: LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
349
|
-
payload: msg === null || msg === void 0 ? void 0 : (_msg$
|
|
366
|
+
payload: msg === null || msg === void 0 ? void 0 : (_msg$payload8 = msg.payload) === null || _msg$payload8 === void 0 ? void 0 : _msg$payload8.customContext
|
|
350
367
|
});
|
|
351
|
-
stateWithUpdatedContext = {
|
|
352
|
-
...state,
|
|
353
|
-
domainStates: {
|
|
354
|
-
...state.domainStates,
|
|
355
|
-
customContext: msg === null || msg === void 0 ? void 0 : (_msg$payload8 = msg.payload) === null || _msg$payload8 === void 0 ? void 0 : _msg$payload8.customContext
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
368
|
}
|
|
359
369
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
360
370
|
Event: TelemetryEvent.StartChatEventRecevied,
|
|
361
371
|
Description: "Start chat event received."
|
|
362
372
|
});
|
|
373
|
+
const inMemoryState = executeReducer(state, {
|
|
374
|
+
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
375
|
+
payload: null
|
|
376
|
+
});
|
|
377
|
+
inMemoryState.domainStates.customContext = msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.customContext;
|
|
363
378
|
|
|
364
|
-
//
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
// Chat not found in cache - scenario: explicitly clearing cache and calling startChat SDK method
|
|
368
|
-
if (persistedState === undefined) {
|
|
379
|
+
// Only initiate new chat if widget runtime state is one of the followings
|
|
380
|
+
if (((_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.conversationState) === ConversationState.Closed || ((_inMemoryState$appSta2 = inMemoryState.appStates) === null || _inMemoryState$appSta2 === void 0 ? void 0 : _inMemoryState$appSta2.conversationState) === ConversationState.InActive || ((_inMemoryState$appSta3 = inMemoryState.appStates) === null || _inMemoryState$appSta3 === void 0 ? void 0 : _inMemoryState$appSta3.conversationState) === ConversationState.Postchat) {
|
|
369
381
|
BroadcastService.postMessage({
|
|
370
382
|
eventName: BroadcastEvent.ChatInitiated
|
|
371
383
|
});
|
|
372
|
-
prepareStartChat(props, chatSDK,
|
|
384
|
+
prepareStartChat(props, chatSDK, inMemoryState, dispatch, setAdapter);
|
|
373
385
|
return;
|
|
374
386
|
}
|
|
375
387
|
|
|
376
|
-
//
|
|
377
|
-
if (
|
|
378
|
-
var
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
dispatch({
|
|
392
|
-
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
393
|
-
payload: false
|
|
394
|
-
});
|
|
395
|
-
BroadcastService.postMessage({
|
|
396
|
-
eventName: BroadcastEvent.MaximizeChat,
|
|
397
|
-
payload: {
|
|
398
|
-
height: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : (_persistedState$domai2 = _persistedState$domai.widgetSize) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.height,
|
|
399
|
-
width: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai3 = persistedState.domainStates) === null || _persistedState$domai3 === void 0 ? void 0 : (_persistedState$domai4 = _persistedState$domai3.widgetSize) === null || _persistedState$domai4 === void 0 ? void 0 : _persistedState$domai4.width
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
}
|
|
388
|
+
// If minimized, maximize the chat
|
|
389
|
+
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta4 = inMemoryState.appStates) === null || _inMemoryState$appSta4 === void 0 ? void 0 : _inMemoryState$appSta4.isMinimized) === true) {
|
|
390
|
+
var _inMemoryState$domain, _inMemoryState$domain2, _inMemoryState$domain3, _inMemoryState$domain4;
|
|
391
|
+
dispatch({
|
|
392
|
+
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
393
|
+
payload: false
|
|
394
|
+
});
|
|
395
|
+
BroadcastService.postMessage({
|
|
396
|
+
eventName: BroadcastEvent.MaximizeChat,
|
|
397
|
+
payload: {
|
|
398
|
+
height: inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain = inMemoryState.domainStates) === null || _inMemoryState$domain === void 0 ? void 0 : (_inMemoryState$domain2 = _inMemoryState$domain.widgetSize) === null || _inMemoryState$domain2 === void 0 ? void 0 : _inMemoryState$domain2.height,
|
|
399
|
+
width: inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain3 = inMemoryState.domainStates) === null || _inMemoryState$domain3 === void 0 ? void 0 : (_inMemoryState$domain4 = _inMemoryState$domain3.widgetSize) === null || _inMemoryState$domain4 === void 0 ? void 0 : _inMemoryState$domain4.width
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
return;
|
|
403
403
|
}
|
|
404
404
|
});
|
|
405
405
|
|
|
@@ -448,8 +448,8 @@ export const LiveChatWidgetStateful = props => {
|
|
|
448
448
|
// Listen to end chat event from other tabs
|
|
449
449
|
const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.widgetId, ((_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
450
450
|
BroadcastService.getMessageByEventName(endChatEventName).subscribe(msg => {
|
|
451
|
-
var _msg$
|
|
452
|
-
if ((msg === null || msg === void 0 ? void 0 : (_msg$
|
|
451
|
+
var _msg$payload10;
|
|
452
|
+
if ((msg === null || msg === void 0 ? void 0 : (_msg$payload10 = msg.payload) === null || _msg$payload10 === void 0 ? void 0 : _msg$payload10.runtimeId) !== TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
453
453
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
454
454
|
Event: TelemetryEvent.PrepareEndChat,
|
|
455
455
|
Description: "Received EndChat BroadcastEvent from other tabs. Closing this chat."
|