@microsoft/omnichannel-chat-widget 1.8.1-main.3ee330c → 1.8.1-main.4fb8cb5
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/facades/FacadeChatSDK.js +0 -42
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +3 -4
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +1 -1
- package/lib/cjs/components/livechatwidget/common/persistentChatHelper.js +5 -12
- package/lib/cjs/components/livechatwidget/common/startChat.js +2 -2
- package/lib/esm/common/facades/FacadeChatSDK.js +0 -42
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +3 -4
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +1 -1
- package/lib/esm/components/livechatwidget/common/persistentChatHelper.js +5 -12
- package/lib/esm/components/livechatwidget/common/startChat.js +2 -2
- package/lib/types/common/facades/FacadeChatSDK.d.ts +0 -1
- package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/persistentChatHelper.d.ts +1 -2
- package/package.json +1 -1
|
@@ -445,48 +445,6 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
445
445
|
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
446
446
|
return this.validateAndExecuteCall("getAgentAvailability", () => this.chatSDK.getAgentAvailability(optionalParams));
|
|
447
447
|
}
|
|
448
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
449
|
-
}, {
|
|
450
|
-
key: "getReconnectableChats",
|
|
451
|
-
value: async function getReconnectableChats() {
|
|
452
|
-
let reconnectableChatsParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
453
|
-
/**
|
|
454
|
-
*
|
|
455
|
-
* This is a particular case, we dont expose getReconnectableChats in the SDK,
|
|
456
|
-
* The only way to use is by tunneling directly from the SDK to OCSDK,
|
|
457
|
-
*
|
|
458
|
-
* In case of prechat, the function is called before any formal authentication is made,
|
|
459
|
-
* this is an specific case for persistent chats, to prevent the survey be loaded again for an on going chat,
|
|
460
|
-
*
|
|
461
|
-
* In this case, we check for existance of the token , otherwise we perform the authentication, error is propagated in case of issues.
|
|
462
|
-
*
|
|
463
|
-
* Once the token is obtained , this will be added to the params to call the function.
|
|
464
|
-
*
|
|
465
|
-
* This is a particular case, should not be taken as pattern.
|
|
466
|
-
*
|
|
467
|
-
*/
|
|
468
|
-
|
|
469
|
-
if (this.token === null || this.token === "") {
|
|
470
|
-
// If token is not set, try to get it using tokenRing
|
|
471
|
-
const pingResponse = await this.tokenRing();
|
|
472
|
-
if (pingResponse.result === false) {
|
|
473
|
-
const errorMessage = `Authentication failed: Process to get a token failed for getReconnectableChats, ${pingResponse.message}`;
|
|
474
|
-
//telemetry is already logged in tokenRing, so no need to log again, just return the error and communicate to the console
|
|
475
|
-
console.error(errorMessage);
|
|
476
|
-
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
477
|
-
eventName: _TelemetryConstants.BroadcastEvent.OnWidgetError,
|
|
478
|
-
payload: {
|
|
479
|
-
errorMessage: errorMessage
|
|
480
|
-
}
|
|
481
|
-
});
|
|
482
|
-
throw new Error(errorMessage);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
// Always override the token in params regardless of how getReconnectableChats was called
|
|
487
|
-
reconnectableChatsParams.authenticatedUserToken = this.token;
|
|
488
|
-
return this.validateAndExecuteCall("getReconnectableChats", () => this.chatSDK.OCClient.getReconnectableChats(reconnectableChatsParams));
|
|
489
|
-
}
|
|
490
448
|
}]);
|
|
491
449
|
return FacadeChatSDK;
|
|
492
450
|
}();
|
|
@@ -16,15 +16,14 @@ var _createReducer = require("../../contexts/createReducer");
|
|
|
16
16
|
var _LiveChatWidgetContextInitialState = require("../../contexts/common/LiveChatWidgetContextInitialState");
|
|
17
17
|
var _getMockChatSDKIfApplicable = require("./common/getMockChatSDKIfApplicable");
|
|
18
18
|
var _utils = require("../../common/utils");
|
|
19
|
-
var _liveChatConfigUtils = require("./common/liveChatConfigUtils");
|
|
20
|
-
var _startChatErrorHandler = require("./common/startChatErrorHandler");
|
|
21
19
|
var _overridePropsOnMockIfApplicable = _interopRequireDefault(require("./common/overridePropsOnMockIfApplicable"));
|
|
22
20
|
var _registerTelemetryLoggers = require("./common/registerTelemetryLoggers");
|
|
21
|
+
var _startChatErrorHandler = require("./common/startChatErrorHandler");
|
|
23
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
23
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
26
25
|
const LiveChatWidget = props => {
|
|
27
|
-
var _props$mock, _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv
|
|
26
|
+
var _props$mock, _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv;
|
|
28
27
|
const reducer = (0, _createReducer.createReducer)();
|
|
29
28
|
const [state, dispatch] = (0, _react.useReducer)(reducer, (0, _LiveChatWidgetContextInitialState.getLiveChatWidgetContextInitialState)(props));
|
|
30
29
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -38,7 +37,7 @@ const LiveChatWidget = props => {
|
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
-
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)
|
|
40
|
+
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);
|
|
42
41
|
if (!facadeChatSDK) {
|
|
43
42
|
var _props$mock2;
|
|
44
43
|
setFacadeChatSDK(new _FacadeChatSDK.FacadeChatSDK({
|
|
@@ -13,7 +13,7 @@ const isPostChatSurveyEnabled = async facadeChatSDK => {
|
|
|
13
13
|
return postChatEnabled === "true";
|
|
14
14
|
};
|
|
15
15
|
exports.isPostChatSurveyEnabled = isPostChatSurveyEnabled;
|
|
16
|
-
const isPersistentChatEnabled = conversationMode => {
|
|
16
|
+
const isPersistentChatEnabled = async conversationMode => {
|
|
17
17
|
if ((0, _utils.isNullOrUndefined)(conversationMode)) {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
@@ -6,23 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.shouldSetPreChatIfPersistentChat = void 0;
|
|
7
7
|
var _liveChatConfigUtils = require("./liveChatConfigUtils");
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
-
const shouldSetPreChatIfPersistentChat = async (
|
|
10
|
-
const persistentEnabled = (0, _liveChatConfigUtils.isPersistentChatEnabled)(conversationMode);
|
|
9
|
+
const shouldSetPreChatIfPersistentChat = async (chatSDK, conversationMode, showPreChat) => {
|
|
10
|
+
const persistentEnabled = await (0, _liveChatConfigUtils.isPersistentChatEnabled)(conversationMode);
|
|
11
11
|
let skipPreChat = false;
|
|
12
12
|
if (persistentEnabled) {
|
|
13
|
-
// Access private properties using type assertions
|
|
14
|
-
const chatSDK = facadeChatSDK.getChatSDK();
|
|
15
|
-
|
|
16
|
-
// Use type assertion to bypass private access restriction
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
-
const sdkAsAny = chatSDK;
|
|
19
|
-
// most likely this is not set , the facade will take care of it
|
|
20
13
|
const reconnectableChatsParams = {
|
|
21
|
-
authenticatedUserToken:
|
|
22
|
-
requestId:
|
|
14
|
+
authenticatedUserToken: chatSDK.authenticatedUserToken,
|
|
15
|
+
requestId: chatSDK.requestId
|
|
23
16
|
};
|
|
24
17
|
try {
|
|
25
|
-
const reconnectableChatsResponse = await
|
|
18
|
+
const reconnectableChatsResponse = await chatSDK.OCClient.getReconnectableChats(reconnectableChatsParams);
|
|
26
19
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
|
27
20
|
// Skip rendering prechat on existing persistent chat session
|
|
28
21
|
skipPreChat = true;
|
|
@@ -75,7 +75,7 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
|
|
|
75
75
|
const parseToJson = false;
|
|
76
76
|
const preChatSurveyResponse = (props === null || props === void 0 ? void 0 : (_props$preChatSurveyP = props.preChatSurveyPaneProps) === null || _props$preChatSurveyP === void 0 ? void 0 : (_props$preChatSurveyP2 = _props$preChatSurveyP.controlProps) === null || _props$preChatSurveyP2 === void 0 ? void 0 : _props$preChatSurveyP2.payload) ?? (await facadeChatSDK.getPreChatSurvey(parseToJson));
|
|
77
77
|
let showPrechat = isProactiveChat ? preChatSurveyResponse && proactiveChatEnablePrechatState : preChatSurveyResponse && !(props !== null && props !== void 0 && (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hidePreChatSurveyPane);
|
|
78
|
-
showPrechat = await (0, _persistentChatHelper.shouldSetPreChatIfPersistentChat)(facadeChatSDK, 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$l2.msdyn_conversationmode, showPrechat);
|
|
78
|
+
showPrechat = await (0, _persistentChatHelper.shouldSetPreChatIfPersistentChat)(facadeChatSDK.getChatSDK(), 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$l2.msdyn_conversationmode, showPrechat);
|
|
79
79
|
if (showPrechat) {
|
|
80
80
|
var _state$domainStates2, _state$domainStates2$, _state$domainStates2$2, _state$domainStates2$3;
|
|
81
81
|
const isOutOfOperatingHours = (state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : (_state$domainStates2$ = _state$domainStates2.liveChatConfig) === null || _state$domainStates2$ === void 0 ? void 0 : (_state$domainStates2$2 = _state$domainStates2$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates2$2 === void 0 ? void 0 : (_state$domainStates2$3 = _state$domainStates2$2.OutOfOperatingHours) === null || _state$domainStates2$3 === void 0 ? void 0 : _state$domainStates2$3.toString().toLowerCase()) === "true";
|
|
@@ -163,7 +163,7 @@ exports.setPreChatAndInitiateChat = setPreChatAndInitiateChat;
|
|
|
163
163
|
const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props, params, persistedState) => {
|
|
164
164
|
var _state$domainStates7, _state$domainStates7$, _state$domainStates7$2;
|
|
165
165
|
let isStartChatSuccessful = false;
|
|
166
|
-
const persistentChatEnabled = (0, _liveChatConfigUtils.isPersistentChatEnabled)(state === null || state === void 0 ? void 0 : (_state$domainStates7 = state.domainStates) === null || _state$domainStates7 === void 0 ? void 0 : (_state$domainStates7$ = _state$domainStates7.liveChatConfig) === null || _state$domainStates7$ === void 0 ? void 0 : (_state$domainStates7$2 = _state$domainStates7$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates7$2 === void 0 ? void 0 : _state$domainStates7$2.msdyn_conversationmode);
|
|
166
|
+
const persistentChatEnabled = await (0, _liveChatConfigUtils.isPersistentChatEnabled)(state === null || state === void 0 ? void 0 : (_state$domainStates7 = state.domainStates) === null || _state$domainStates7 === void 0 ? void 0 : (_state$domainStates7$ = _state$domainStates7.liveChatConfig) === null || _state$domainStates7$ === void 0 ? void 0 : (_state$domainStates7$2 = _state$domainStates7$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates7$2 === void 0 ? void 0 : _state$domainStates7$2.msdyn_conversationmode);
|
|
167
167
|
if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === _ConversationState.ConversationState.Closed) {
|
|
168
168
|
// Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
|
|
169
169
|
(0, _endChat.chatSDKStateCleanUp)(facadeChatSDK.getChatSDK());
|
|
@@ -439,48 +439,6 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
439
439
|
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
440
440
|
return this.validateAndExecuteCall("getAgentAvailability", () => this.chatSDK.getAgentAvailability(optionalParams));
|
|
441
441
|
}
|
|
442
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
443
|
-
}, {
|
|
444
|
-
key: "getReconnectableChats",
|
|
445
|
-
value: async function getReconnectableChats() {
|
|
446
|
-
let reconnectableChatsParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
447
|
-
/**
|
|
448
|
-
*
|
|
449
|
-
* This is a particular case, we dont expose getReconnectableChats in the SDK,
|
|
450
|
-
* The only way to use is by tunneling directly from the SDK to OCSDK,
|
|
451
|
-
*
|
|
452
|
-
* In case of prechat, the function is called before any formal authentication is made,
|
|
453
|
-
* this is an specific case for persistent chats, to prevent the survey be loaded again for an on going chat,
|
|
454
|
-
*
|
|
455
|
-
* In this case, we check for existance of the token , otherwise we perform the authentication, error is propagated in case of issues.
|
|
456
|
-
*
|
|
457
|
-
* Once the token is obtained , this will be added to the params to call the function.
|
|
458
|
-
*
|
|
459
|
-
* This is a particular case, should not be taken as pattern.
|
|
460
|
-
*
|
|
461
|
-
*/
|
|
462
|
-
|
|
463
|
-
if (this.token === null || this.token === "") {
|
|
464
|
-
// If token is not set, try to get it using tokenRing
|
|
465
|
-
const pingResponse = await this.tokenRing();
|
|
466
|
-
if (pingResponse.result === false) {
|
|
467
|
-
const errorMessage = `Authentication failed: Process to get a token failed for getReconnectableChats, ${pingResponse.message}`;
|
|
468
|
-
//telemetry is already logged in tokenRing, so no need to log again, just return the error and communicate to the console
|
|
469
|
-
console.error(errorMessage);
|
|
470
|
-
BroadcastService.postMessage({
|
|
471
|
-
eventName: BroadcastEvent.OnWidgetError,
|
|
472
|
-
payload: {
|
|
473
|
-
errorMessage: errorMessage
|
|
474
|
-
}
|
|
475
|
-
});
|
|
476
|
-
throw new Error(errorMessage);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
// Always override the token in params regardless of how getReconnectableChats was called
|
|
481
|
-
reconnectableChatsParams.authenticatedUserToken = this.token;
|
|
482
|
-
return this.validateAndExecuteCall("getReconnectableChats", () => this.chatSDK.OCClient.getReconnectableChats(reconnectableChatsParams));
|
|
483
|
-
}
|
|
484
442
|
}]);
|
|
485
443
|
return FacadeChatSDK;
|
|
486
444
|
}();
|
|
@@ -10,12 +10,11 @@ import { createReducer } from "../../contexts/createReducer";
|
|
|
10
10
|
import { getLiveChatWidgetContextInitialState } from "../../contexts/common/LiveChatWidgetContextInitialState";
|
|
11
11
|
import { getMockChatSDKIfApplicable } from "./common/getMockChatSDKIfApplicable";
|
|
12
12
|
import { isNullOrUndefined } from "../../common/utils";
|
|
13
|
-
import { isPersistentChatEnabled } from "./common/liveChatConfigUtils";
|
|
14
|
-
import { logWidgetLoadWithUnexpectedError } from "./common/startChatErrorHandler";
|
|
15
13
|
import overridePropsOnMockIfApplicable from "./common/overridePropsOnMockIfApplicable";
|
|
16
14
|
import { registerTelemetryLoggers } from "./common/registerTelemetryLoggers";
|
|
15
|
+
import { logWidgetLoadWithUnexpectedError } from "./common/startChatErrorHandler";
|
|
17
16
|
export const LiveChatWidget = props => {
|
|
18
|
-
var _props$mock, _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv
|
|
17
|
+
var _props$mock, _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv;
|
|
19
18
|
const reducer = createReducer();
|
|
20
19
|
const [state, dispatch] = useReducer(reducer, getLiveChatWidgetContextInitialState(props));
|
|
21
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -29,7 +28,7 @@ export const LiveChatWidget = props => {
|
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
-
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)
|
|
31
|
+
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);
|
|
33
32
|
if (!facadeChatSDK) {
|
|
34
33
|
var _props$mock2;
|
|
35
34
|
setFacadeChatSDK(new FacadeChatSDK({
|
|
@@ -6,7 +6,7 @@ export const isPostChatSurveyEnabled = async facadeChatSDK => {
|
|
|
6
6
|
const postChatEnabled = (_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : _chatConfig$LiveWSAnd.msdyn_postconversationsurveyenable.toString().toLowerCase();
|
|
7
7
|
return postChatEnabled === "true";
|
|
8
8
|
};
|
|
9
|
-
export const isPersistentChatEnabled = conversationMode => {
|
|
9
|
+
export const isPersistentChatEnabled = async conversationMode => {
|
|
10
10
|
if (isNullOrUndefined(conversationMode)) {
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
import { isPersistentChatEnabled } from "./liveChatConfigUtils";
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
-
export const shouldSetPreChatIfPersistentChat = async (
|
|
5
|
-
const persistentEnabled = isPersistentChatEnabled(conversationMode);
|
|
4
|
+
export const shouldSetPreChatIfPersistentChat = async (chatSDK, conversationMode, showPreChat) => {
|
|
5
|
+
const persistentEnabled = await isPersistentChatEnabled(conversationMode);
|
|
6
6
|
let skipPreChat = false;
|
|
7
7
|
if (persistentEnabled) {
|
|
8
|
-
// Access private properties using type assertions
|
|
9
|
-
const chatSDK = facadeChatSDK.getChatSDK();
|
|
10
|
-
|
|
11
|
-
// Use type assertion to bypass private access restriction
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
-
const sdkAsAny = chatSDK;
|
|
14
|
-
// most likely this is not set , the facade will take care of it
|
|
15
8
|
const reconnectableChatsParams = {
|
|
16
|
-
authenticatedUserToken:
|
|
17
|
-
requestId:
|
|
9
|
+
authenticatedUserToken: chatSDK.authenticatedUserToken,
|
|
10
|
+
requestId: chatSDK.requestId
|
|
18
11
|
};
|
|
19
12
|
try {
|
|
20
|
-
const reconnectableChatsResponse = await
|
|
13
|
+
const reconnectableChatsResponse = await chatSDK.OCClient.getReconnectableChats(reconnectableChatsParams);
|
|
21
14
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
|
22
15
|
// Skip rendering prechat on existing persistent chat session
|
|
23
16
|
skipPreChat = true;
|
|
@@ -69,7 +69,7 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
|
|
|
69
69
|
const parseToJson = false;
|
|
70
70
|
const preChatSurveyResponse = (props === null || props === void 0 ? void 0 : (_props$preChatSurveyP = props.preChatSurveyPaneProps) === null || _props$preChatSurveyP === void 0 ? void 0 : (_props$preChatSurveyP2 = _props$preChatSurveyP.controlProps) === null || _props$preChatSurveyP2 === void 0 ? void 0 : _props$preChatSurveyP2.payload) ?? (await facadeChatSDK.getPreChatSurvey(parseToJson));
|
|
71
71
|
let showPrechat = isProactiveChat ? preChatSurveyResponse && proactiveChatEnablePrechatState : preChatSurveyResponse && !(props !== null && props !== void 0 && (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hidePreChatSurveyPane);
|
|
72
|
-
showPrechat = await shouldSetPreChatIfPersistentChat(facadeChatSDK, 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$l2.msdyn_conversationmode, showPrechat);
|
|
72
|
+
showPrechat = await shouldSetPreChatIfPersistentChat(facadeChatSDK.getChatSDK(), 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$l2.msdyn_conversationmode, showPrechat);
|
|
73
73
|
if (showPrechat) {
|
|
74
74
|
var _state$domainStates2, _state$domainStates2$, _state$domainStates2$2, _state$domainStates2$3;
|
|
75
75
|
const isOutOfOperatingHours = (state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : (_state$domainStates2$ = _state$domainStates2.liveChatConfig) === null || _state$domainStates2$ === void 0 ? void 0 : (_state$domainStates2$2 = _state$domainStates2$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates2$2 === void 0 ? void 0 : (_state$domainStates2$3 = _state$domainStates2$2.OutOfOperatingHours) === null || _state$domainStates2$3 === void 0 ? void 0 : _state$domainStates2$3.toString().toLowerCase()) === "true";
|
|
@@ -156,7 +156,7 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
|
|
|
156
156
|
const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props, params, persistedState) => {
|
|
157
157
|
var _state$domainStates7, _state$domainStates7$, _state$domainStates7$2;
|
|
158
158
|
let isStartChatSuccessful = false;
|
|
159
|
-
const persistentChatEnabled = isPersistentChatEnabled(state === null || state === void 0 ? void 0 : (_state$domainStates7 = state.domainStates) === null || _state$domainStates7 === void 0 ? void 0 : (_state$domainStates7$ = _state$domainStates7.liveChatConfig) === null || _state$domainStates7$ === void 0 ? void 0 : (_state$domainStates7$2 = _state$domainStates7$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates7$2 === void 0 ? void 0 : _state$domainStates7$2.msdyn_conversationmode);
|
|
159
|
+
const persistentChatEnabled = await isPersistentChatEnabled(state === null || state === void 0 ? void 0 : (_state$domainStates7 = state.domainStates) === null || _state$domainStates7 === void 0 ? void 0 : (_state$domainStates7$ = _state$domainStates7.liveChatConfig) === null || _state$domainStates7$ === void 0 ? void 0 : (_state$domainStates7$2 = _state$domainStates7$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates7$2 === void 0 ? void 0 : _state$domainStates7$2.msdyn_conversationmode);
|
|
160
160
|
if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === ConversationState.Closed) {
|
|
161
161
|
// Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
|
|
162
162
|
chatSDKStateCleanUp(facadeChatSDK.getChatSDK());
|
|
@@ -72,5 +72,4 @@ export declare class FacadeChatSDK {
|
|
|
72
72
|
getVoiceVideoCalling(params?: VoiceVideoCallingOptionalParams): Promise<GetVoiceVideoCallingResponse>;
|
|
73
73
|
getPostChatSurveyContext(): Promise<PostChatContext>;
|
|
74
74
|
getAgentAvailability(optionalParams?: GetAgentAvailabilityOptionalParams): Promise<GetAgentAvailabilityResponse>;
|
|
75
|
-
getReconnectableChats(reconnectableChatsParams?: any): Promise<any>;
|
|
76
75
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
|
|
2
2
|
export declare const isPostChatSurveyEnabled: (facadeChatSDK: FacadeChatSDK) => Promise<boolean>;
|
|
3
|
-
export declare const isPersistentChatEnabled: (conversationMode: string | undefined) => boolean
|
|
3
|
+
export declare const isPersistentChatEnabled: (conversationMode: string | undefined) => Promise<boolean>;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const shouldSetPreChatIfPersistentChat: (facadeChatSDK: FacadeChatSDK, conversationMode: string, showPreChat: boolean) => Promise<boolean>;
|
|
1
|
+
export declare const shouldSetPreChatIfPersistentChat: (chatSDK: any, conversationMode: string, showPreChat: boolean) => Promise<boolean>;
|