@microsoft/omnichannel-chat-widget 0.1.0-main.9e62ed8 → 0.1.0-main.a27ec4b
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 +4 -0
- package/lib/cjs/common/storage/default/defaultCacheManager.js +34 -0
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +114 -0
- package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +86 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +12 -0
- package/lib/cjs/common/utils.js +64 -5
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +4 -0
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/cjs/components/footerstateful/FooterStateful.js +1 -8
- package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -3
- package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
- package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
- package/lib/cjs/components/livechatwidget/common/authHelper.js +65 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
- package/lib/cjs/components/livechatwidget/common/createFooter.js +7 -16
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +12 -0
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +23 -5
- package/lib/cjs/components/livechatwidget/common/endChat.js +52 -20
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +12 -0
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +55 -35
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +153 -85
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +188 -116
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -8
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +12 -5
- package/lib/cjs/contexts/createReducer.js +8 -0
- package/lib/cjs/controller/componentController.js +2 -2
- package/lib/esm/common/Constants.js +4 -0
- package/lib/esm/common/storage/default/defaultCacheManager.js +19 -0
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +102 -0
- package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +71 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +12 -0
- package/lib/esm/common/utils.js +48 -3
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -0
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/esm/components/footerstateful/FooterStateful.js +1 -8
- package/lib/esm/components/headerstateful/HeaderStateful.js +4 -3
- package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
- package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
- package/lib/esm/components/livechatwidget/common/authHelper.js +50 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
- package/lib/esm/components/livechatwidget/common/createFooter.js +4 -15
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +8 -0
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +23 -5
- package/lib/esm/components/livechatwidget/common/endChat.js +53 -21
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -2
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +56 -37
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +148 -86
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +188 -117
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -8
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +14 -2
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +10 -5
- package/lib/esm/contexts/createReducer.js +8 -0
- package/lib/esm/controller/componentController.js +2 -2
- package/lib/types/common/Constants.d.ts +2 -0
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
- package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +11 -2
- package/lib/types/common/utils.d.ts +7 -3
- package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
- package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
- package/lib/types/contexts/common/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
- package/package.json +4 -3
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.removeAuthTokenProvider = exports.handleAuthentication = exports.getAuthClientFunction = void 0;
|
|
7
|
+
|
|
8
|
+
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
|
+
|
|
10
|
+
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
11
|
+
|
|
12
|
+
var _utils = require("../../../common/utils");
|
|
13
|
+
|
|
14
|
+
const getAuthClientFunction = chatConfig => {
|
|
15
|
+
let authClientFunction = undefined;
|
|
16
|
+
|
|
17
|
+
if (chatConfig !== null && chatConfig !== void 0 && chatConfig.LiveChatConfigAuthSettings) {
|
|
18
|
+
var _chatConfig$LiveChatC;
|
|
19
|
+
|
|
20
|
+
authClientFunction = (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig$LiveChatC = chatConfig.LiveChatConfigAuthSettings) === null || _chatConfig$LiveChatC === void 0 ? void 0 : _chatConfig$LiveChatC.msdyn_javascriptclientfunction) ?? undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return authClientFunction;
|
|
24
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
exports.getAuthClientFunction = getAuthClientFunction;
|
|
28
|
+
|
|
29
|
+
const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
30
|
+
const authClientFunction = getAuthClientFunction(chatConfig);
|
|
31
|
+
|
|
32
|
+
if (getAuthToken && authClientFunction) {
|
|
33
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
34
|
+
Event: _TelemetryConstants.TelemetryEvent.GetAuthTokenCalled
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const token = await getAuthToken(authClientFunction);
|
|
38
|
+
|
|
39
|
+
if (!(0, _utils.isNullOrEmptyString)(token)) {
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
chatSDK.setAuthTokenProvider(async () => {
|
|
42
|
+
return token;
|
|
43
|
+
});
|
|
44
|
+
return true;
|
|
45
|
+
} else {
|
|
46
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
47
|
+
Event: _TelemetryConstants.TelemetryEvent.ReceivedNullOrEmptyToken
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return false;
|
|
55
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
exports.handleAuthentication = handleAuthentication;
|
|
59
|
+
|
|
60
|
+
const removeAuthTokenProvider = chatSDK => {
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
+
chatSDK.authenticatedUserToken = null;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
exports.removeAuthTokenProvider = removeAuthTokenProvider;
|
|
@@ -13,6 +13,10 @@ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcont
|
|
|
13
13
|
|
|
14
14
|
var _defaultMiddlewareLocalizedTexts = require("../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
15
15
|
|
|
16
|
+
var _ChatAdapterShim = require("./ChatAdapterShim");
|
|
17
|
+
|
|
18
|
+
var _PauseActivitySubscriber = require("./ActivitySubscriber/PauseActivitySubscriber");
|
|
19
|
+
|
|
16
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
21
|
const createAdapter = async chatSDK => {
|
|
18
22
|
const chatAdapterOptionalParams = {
|
|
@@ -34,7 +38,15 @@ const createAdapter = async chatSDK => {
|
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
};
|
|
37
|
-
|
|
41
|
+
let adapter = await chatSDK.createChatAdapter(chatAdapterOptionalParams); //so far, there is no need to convert to the shim adapter when using visual tests
|
|
42
|
+
|
|
43
|
+
if (chatSDK.isMockModeOn !== true) {
|
|
44
|
+
adapter = new _ChatAdapterShim.ChatAdapterShim(adapter);
|
|
45
|
+
adapter.addSubscriber(new _PauseActivitySubscriber.PauseActivitySubscriber());
|
|
46
|
+
return adapter.chatAdapter;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return adapter;
|
|
38
50
|
};
|
|
39
51
|
|
|
40
52
|
exports.createAdapter = createAdapter;
|
|
@@ -16,26 +16,17 @@ var _componentController = require("../../../controller/componentController");
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
18
|
const createFooter = (props, state) => {
|
|
19
|
-
var _props$
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
hideEmailTranscriptButton: true,
|
|
25
|
-
hideAudioNotificationButton: true
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
const footer = !((_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideFooter) && (0, _componentController.shouldShowFooter)(state) ? (0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.footer) || /*#__PURE__*/_react.default.createElement(_FooterStateful.default, {
|
|
19
|
+
var _props$controlProps, _props$componentOverr;
|
|
20
|
+
|
|
21
|
+
const hideFooterDisplay = !((_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideFooter) && (0, _componentController.shouldShowFooter)(state) ? false : true;
|
|
22
|
+
|
|
23
|
+
const footer = (0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.footer) || /*#__PURE__*/_react.default.createElement(_FooterStateful.default, {
|
|
29
24
|
footerProps: props.footerProps,
|
|
30
25
|
downloadTranscriptProps: props.downloadTranscriptProps,
|
|
31
26
|
audioNotificationProps: props.audioNotificationProps,
|
|
32
|
-
hideFooterDisplay:
|
|
33
|
-
}) : (0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.footer) || /*#__PURE__*/_react.default.createElement(_FooterStateful.default, {
|
|
34
|
-
footerProps: footerPropsHidden,
|
|
35
|
-
downloadTranscriptProps: props.downloadTranscriptProps,
|
|
36
|
-
audioNotificationProps: props.audioNotificationProps,
|
|
37
|
-
hideFooterDisplay: true
|
|
27
|
+
hideFooterDisplay: hideFooterDisplay
|
|
38
28
|
});
|
|
29
|
+
|
|
39
30
|
return footer;
|
|
40
31
|
};
|
|
41
32
|
|
|
@@ -13,6 +13,10 @@ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcont
|
|
|
13
13
|
|
|
14
14
|
var _defaultMiddlewareLocalizedTexts = require("../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
15
15
|
|
|
16
|
+
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
17
|
+
|
|
18
|
+
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
19
|
+
|
|
16
20
|
const isInternetConnected = async () => {
|
|
17
21
|
try {
|
|
18
22
|
const response = await fetch(_Constants.Constants.internetConnectionTestUrl);
|
|
@@ -28,8 +32,16 @@ const createInternetConnectionChangeHandler = async () => {
|
|
|
28
32
|
const connected = await isInternetConnected();
|
|
29
33
|
|
|
30
34
|
if (!connected) {
|
|
35
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
36
|
+
Event: _TelemetryConstants.TelemetryEvent.NetworkDisconnected
|
|
37
|
+
});
|
|
38
|
+
|
|
31
39
|
_NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.InternetConnection, _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION);
|
|
32
40
|
} else {
|
|
41
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
42
|
+
Event: _TelemetryConstants.TelemetryEvent.NetworkReconnected
|
|
43
|
+
});
|
|
44
|
+
|
|
33
45
|
_NotificationHandler.NotificationHandler.notifySuccess(_NotificationScenarios.NotificationScenarios.InternetConnection, _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE);
|
|
34
46
|
}
|
|
35
47
|
}; // Checking connection status on online & offline events due to possible false positives
|
|
@@ -26,26 +26,40 @@ const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdown
|
|
|
26
26
|
breaks: !disableNewLineMarkdownSupport
|
|
27
27
|
}); // ToDo: Commenting below usage of plugin until deferred bug is resolved: https://github.com/mayashavin/markdown-it-slack/issues/1
|
|
28
28
|
// markdown.use(MarkdownSlack);
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
} else {
|
|
30
|
+
markdown = new _markdownIt.default(_Constants.Constants.Zero, {
|
|
31
|
+
html: true,
|
|
32
|
+
linkify: true,
|
|
33
|
+
breaks: !disableNewLineMarkdownSupport
|
|
34
|
+
});
|
|
35
|
+
markdown.enable(["entity", // Rule to process html entity - {, ¯, "
|
|
36
|
+
"linkify", // Rule to replace link-like texts with link nodes
|
|
37
|
+
"html_block", // Rule to process html blocks and paragraphs
|
|
38
|
+
"html_inline", // Rule to process html tags
|
|
39
|
+
"newline" // Rule to proceess '\n'
|
|
40
|
+
]);
|
|
41
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
42
|
|
|
32
|
-
markdown.use(_markdownItForInline.default, "url_new_win", "link_open", function (tokens, idx, env) {
|
|
33
|
-
const targetAttrIndex = tokens[idx].attrIndex(_Constants.Constants.Target); // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
|
|
34
43
|
|
|
35
|
-
|
|
44
|
+
markdown.use(_markdownItForInline.default, "url_new_win", "link_open", function (tokens, idx, env) {
|
|
45
|
+
const targetAttrIndex = tokens[idx].attrIndex(_Constants.Constants.Target); // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
|
|
36
46
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
48
|
+
|
|
49
|
+
if (~targetAttrIndex) {
|
|
50
|
+
tokens[idx].attrs[targetAttrIndex][1] = _Constants.Constants.Blank;
|
|
51
|
+
} else {
|
|
52
|
+
tokens[idx].attrPush([_Constants.Constants.Target, _Constants.Constants.Blank]);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const relAttrIndex = tokens[idx].attrIndex(_Constants.Constants.TargetRelationship);
|
|
42
56
|
|
|
43
|
-
|
|
57
|
+
if (~relAttrIndex) {
|
|
58
|
+
tokens[idx].attrs[relAttrIndex][1] = _Constants.Constants.TargetRelationshipAttributes;
|
|
59
|
+
} else {
|
|
60
|
+
tokens[idx].attrPush([_Constants.Constants.TargetRelationship, _Constants.Constants.TargetRelationshipAttributes]);
|
|
44
61
|
|
|
45
|
-
if (
|
|
46
|
-
tokens[idx].attrs[relAttrIndex][1] = _Constants.Constants.TargetRelationshipAttributes;
|
|
47
|
-
} else {
|
|
48
|
-
tokens[idx].attrPush([_Constants.Constants.TargetRelationship, _Constants.Constants.TargetRelationshipAttributes]);
|
|
62
|
+
if (!disableMarkdownMessageFormatting) {
|
|
49
63
|
tokens[idx].attrPush([_Constants.Constants.Title, _defaultMarkdownLocalizedTexts.defaultMarkdownLocalizedTexts.MARKDOWN_EXTERNAL_LINK_ALT]); // eslint-disable-next-line quotes
|
|
50
64
|
|
|
51
65
|
const iconTokens = markdown.parseInline(``, env)[0].children;
|
|
@@ -55,21 +69,8 @@ const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdown
|
|
|
55
69
|
tokens.splice(idx + 2, 0, ...iconTokens);
|
|
56
70
|
}
|
|
57
71
|
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
markdown = new _markdownIt.default(_Constants.Constants.Zero, {
|
|
61
|
-
html: true,
|
|
62
|
-
linkify: true,
|
|
63
|
-
breaks: !disableNewLineMarkdownSupport
|
|
64
|
-
});
|
|
65
|
-
markdown.enable(["entity", // Rule to process html entity - {, ¯, "
|
|
66
|
-
"linkify", // Rule to replace link-like texts with link nodes
|
|
67
|
-
"html_block", // Rule to process html blocks and paragraphs
|
|
68
|
-
"html_inline", // Rule to process html tags
|
|
69
|
-
"newline" // Rule to proceess '\n'
|
|
70
|
-
]);
|
|
71
|
-
}
|
|
72
|
-
|
|
72
|
+
}
|
|
73
|
+
});
|
|
73
74
|
return markdown;
|
|
74
75
|
};
|
|
75
76
|
|
|
@@ -339,7 +339,8 @@ const dummyDefaultProps = {
|
|
|
339
339
|
hideChatTitle: false,
|
|
340
340
|
hideNotificationBubble: true,
|
|
341
341
|
unreadMessageString: "new messages",
|
|
342
|
-
largeUnreadMessageString: "99+"
|
|
342
|
+
largeUnreadMessageString: "99+",
|
|
343
|
+
ariaLabelUnreadMessageString: "you have new messages"
|
|
343
344
|
},
|
|
344
345
|
styleProps: {
|
|
345
346
|
generalStyleProps: {
|
|
@@ -890,7 +891,7 @@ const dummyDefaultProps = {
|
|
|
890
891
|
className: undefined
|
|
891
892
|
},
|
|
892
893
|
closeButtonProps: {
|
|
893
|
-
id: "oc-lcw-header-
|
|
894
|
+
id: "oc-lcw-header-close-button",
|
|
894
895
|
type: "icon",
|
|
895
896
|
iconName: "ChromeClose",
|
|
896
897
|
ariaLabel: "Close",
|
|
@@ -1206,7 +1207,17 @@ const dummyDefaultProps = {
|
|
|
1206
1207
|
hideSubtitle: false,
|
|
1207
1208
|
subtitleText: "Live chat support!",
|
|
1208
1209
|
hideCloseButton: false,
|
|
1209
|
-
|
|
1210
|
+
closeButtonProps: {
|
|
1211
|
+
id: "oc-lcw-proactivechat-closebutton",
|
|
1212
|
+
type: "icon",
|
|
1213
|
+
iconName: "ChromeClose",
|
|
1214
|
+
ariaLabel: "Close",
|
|
1215
|
+
imageIconProps: undefined,
|
|
1216
|
+
text: "Close",
|
|
1217
|
+
onClick: undefined,
|
|
1218
|
+
className: undefined,
|
|
1219
|
+
hideButtonTitle: true
|
|
1220
|
+
},
|
|
1210
1221
|
isBodyContainerHorizantal: false,
|
|
1211
1222
|
hideBodyTitle: false,
|
|
1212
1223
|
bodyTitleText: "Hi! Have any questions? I am here to help.",
|
|
@@ -1434,7 +1445,6 @@ const dummyDefaultProps = {
|
|
|
1434
1445
|
startNewChatButtonClassName: undefined
|
|
1435
1446
|
}
|
|
1436
1447
|
},
|
|
1437
|
-
authClientFunction: undefined,
|
|
1438
1448
|
isReconnectEnabled: undefined,
|
|
1439
1449
|
reconnectId: undefined,
|
|
1440
1450
|
redirectInSameWindow: undefined
|
|
@@ -1676,6 +1686,9 @@ const dummyDefaultProps = {
|
|
|
1676
1686
|
},
|
|
1677
1687
|
attachmentSizeStyles: {
|
|
1678
1688
|
display: "none"
|
|
1689
|
+
},
|
|
1690
|
+
receivedMessageAnchorStyles: {
|
|
1691
|
+
color: "white"
|
|
1679
1692
|
}
|
|
1680
1693
|
},
|
|
1681
1694
|
localizedTexts: {
|
|
@@ -1703,8 +1716,13 @@ const dummyDefaultProps = {
|
|
|
1703
1716
|
botMagicCode: {
|
|
1704
1717
|
disabled: false,
|
|
1705
1718
|
fwdUrl: ""
|
|
1719
|
+
},
|
|
1720
|
+
adaptiveCardStyles: {
|
|
1721
|
+
background: "white",
|
|
1722
|
+
color: "black"
|
|
1706
1723
|
}
|
|
1707
1724
|
},
|
|
1708
|
-
telemetryConfig: undefined
|
|
1725
|
+
telemetryConfig: undefined,
|
|
1726
|
+
getAuthToken: undefined
|
|
1709
1727
|
};
|
|
1710
1728
|
exports.dummyDefaultProps = dummyDefaultProps;
|
|
@@ -27,18 +27,35 @@ var _utils = require("../../../common/utils");
|
|
|
27
27
|
|
|
28
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
29
|
const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
|
|
30
|
-
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4;
|
|
30
|
+
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
|
|
31
31
|
|
|
32
32
|
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;
|
|
33
|
-
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;
|
|
34
|
-
const conversationDetails = await chatSDK.getConversationDetails();
|
|
33
|
+
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; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
let conversationDetails = undefined;
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
conversationDetails = await chatSDK.getConversationDetails();
|
|
39
|
+
} catch (erorr) {
|
|
40
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
41
|
+
Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsException,
|
|
42
|
+
ExceptionDetails: {
|
|
43
|
+
exception: `Failed to get conversation details: ${erorr}`
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (isPostChatEnabled === "true" && ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.canRenderPostChat) === _Constants.Constants.truePascal) {
|
|
37
49
|
const skipEndChatSDK = false;
|
|
38
50
|
const skipCloseChat = true;
|
|
39
|
-
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat,
|
|
51
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, false);
|
|
40
52
|
|
|
41
53
|
if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
|
|
54
|
+
dispatch({
|
|
55
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
56
|
+
payload: _ConversationState.ConversationState.PostchatLoading
|
|
57
|
+
});
|
|
58
|
+
await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
|
|
42
59
|
const loadPostChatEvent = {
|
|
43
60
|
eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
|
|
44
61
|
};
|
|
@@ -50,9 +67,11 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
50
67
|
payload: _ConversationState.ConversationState.InActive
|
|
51
68
|
});
|
|
52
69
|
}
|
|
53
|
-
|
|
54
|
-
|
|
70
|
+
|
|
71
|
+
return;
|
|
55
72
|
}
|
|
73
|
+
|
|
74
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
|
|
56
75
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
76
|
|
|
58
77
|
|
|
@@ -65,16 +84,7 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
65
84
|
Event: _TelemetryConstants.TelemetryEvent.EndChatSDKCall
|
|
66
85
|
});
|
|
67
86
|
|
|
68
|
-
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
|
|
69
|
-
|
|
70
|
-
dispatch({
|
|
71
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
72
|
-
payload: undefined
|
|
73
|
-
});
|
|
74
|
-
dispatch({
|
|
75
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
76
|
-
payload: undefined
|
|
77
|
-
});
|
|
87
|
+
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
|
|
78
88
|
} catch (ex) {
|
|
79
89
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
80
90
|
Event: _TelemetryConstants.TelemetryEvent.EndChatSDKCallFailed,
|
|
@@ -85,7 +95,21 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
85
95
|
|
|
86
96
|
postMessageToOtherTab = false;
|
|
87
97
|
}
|
|
88
|
-
}
|
|
98
|
+
} // Need to clear these states immediately when chat ended from OC.
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
dispatch({
|
|
102
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
103
|
+
payload: undefined
|
|
104
|
+
});
|
|
105
|
+
dispatch({
|
|
106
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
107
|
+
payload: undefined
|
|
108
|
+
});
|
|
109
|
+
dispatch({
|
|
110
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
111
|
+
payload: undefined
|
|
112
|
+
});
|
|
89
113
|
|
|
90
114
|
if (!skipCloseChat) {
|
|
91
115
|
try {
|
|
@@ -117,11 +141,19 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
117
141
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
118
142
|
payload: 0
|
|
119
143
|
});
|
|
144
|
+
dispatch({
|
|
145
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
146
|
+
payload: {
|
|
147
|
+
proactiveChatBodyTitle: "",
|
|
148
|
+
proactiveChatEnablePrechat: false,
|
|
149
|
+
proactiveChatInNewWindow: false
|
|
150
|
+
}
|
|
151
|
+
});
|
|
120
152
|
|
|
121
153
|
if (postMessageToOtherTab) {
|
|
122
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2;
|
|
154
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps;
|
|
123
155
|
|
|
124
|
-
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(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);
|
|
156
|
+
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(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$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.widgetInstanceId) ?? "");
|
|
125
157
|
|
|
126
158
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
127
159
|
eventName: endChatEventName
|
|
@@ -67,6 +67,8 @@ var _cardActionMiddleware = require("../../webchatcontainerstateful/webchatcontr
|
|
|
67
67
|
|
|
68
68
|
var _messageTimestampMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware"));
|
|
69
69
|
|
|
70
|
+
var _Constants = require("../../../common/Constants");
|
|
71
|
+
|
|
70
72
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
71
73
|
|
|
72
74
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -105,6 +107,12 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
105
107
|
|
|
106
108
|
if (isPostChatEnabled === "true") {
|
|
107
109
|
if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
|
|
110
|
+
_WebChatStoreLoader.WebChatStoreLoader.store = null;
|
|
111
|
+
dispatch({
|
|
112
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
113
|
+
payload: _ConversationState.ConversationState.PostchatLoading
|
|
114
|
+
});
|
|
115
|
+
await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
|
|
108
116
|
const loadPostChatEvent = {
|
|
109
117
|
eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
|
|
110
118
|
};
|
|
@@ -117,6 +125,10 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
117
125
|
});
|
|
118
126
|
}
|
|
119
127
|
} else {
|
|
128
|
+
dispatch({
|
|
129
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
130
|
+
payload: _ConversationState.ConversationState.InActive
|
|
131
|
+
});
|
|
120
132
|
dispatch({
|
|
121
133
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
|
|
122
134
|
payload: true
|
|
@@ -17,24 +17,34 @@ var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidget
|
|
|
17
17
|
|
|
18
18
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
19
19
|
|
|
20
|
+
var _authHelper = require("./authHelper");
|
|
21
|
+
|
|
20
22
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
-
const getChatReconnectContext = async (chatSDK, reconnectId) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
const getChatReconnectContext = async (chatSDK, chatConfig, getAuthToken, isReconnectEnabled, reconnectId) => {
|
|
24
|
+
if (isReconnectEnabled) {
|
|
25
|
+
try {
|
|
26
|
+
if (reconnectId) {
|
|
27
|
+
const chatReconnectOptionalParams = {
|
|
28
|
+
reconnectId: reconnectId
|
|
29
|
+
};
|
|
30
|
+
return await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext(chatReconnectOptionalParams));
|
|
31
|
+
} else {
|
|
32
|
+
// set auth token to chat sdk to get reconnectId for auth chat
|
|
33
|
+
await (0, _authHelper.handleAuthentication)(chatSDK, chatConfig, getAuthToken);
|
|
34
|
+
const reconnectChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext()); // remove auth token after reconnectId is fetched
|
|
35
|
+
// this will be reset later at start chat
|
|
36
|
+
|
|
37
|
+
(0, _authHelper.removeAuthTokenProvider)(chatSDK);
|
|
38
|
+
return reconnectChatContext;
|
|
36
39
|
}
|
|
37
|
-
})
|
|
40
|
+
} catch (ex) {
|
|
41
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
42
|
+
Event: _TelemetryConstants.TelemetryEvent.GetChatReconnectContextSDKCallFailed,
|
|
43
|
+
ExceptionDetails: {
|
|
44
|
+
exception: ex
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
return null;
|
|
@@ -44,13 +54,23 @@ const getChatReconnectContext = async (chatSDK, reconnectId) => {
|
|
|
44
54
|
exports.getChatReconnectContext = getChatReconnectContext;
|
|
45
55
|
|
|
46
56
|
const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
47
|
-
var _props$
|
|
57
|
+
var _props$chatConfig, _props$reconnectChatP;
|
|
58
|
+
|
|
59
|
+
let authClientFunction = undefined;
|
|
48
60
|
|
|
49
|
-
if ((_props$
|
|
61
|
+
if ((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) {
|
|
62
|
+
var _props$chatConfig2, _props$chatConfig2$Li;
|
|
63
|
+
|
|
64
|
+
authClientFunction = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveChatConfigAuthSettings) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_javascriptclientfunction) ?? undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && authClientFunction // TODO: Implement this after storage is in place
|
|
50
68
|
|
|
51
69
|
/* && !isLoadWithState() */
|
|
52
70
|
) {
|
|
53
|
-
|
|
71
|
+
var _props$reconnectChatP2;
|
|
72
|
+
|
|
73
|
+
const previousActiveSessionResponse = await getChatReconnectContext(chatSDK, props.chatConfig, props.getAuthToken, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.isReconnectEnabled);
|
|
54
74
|
|
|
55
75
|
if (previousActiveSessionResponse && previousActiveSessionResponse.reconnectId) {
|
|
56
76
|
return previousActiveSessionResponse.reconnectId;
|
|
@@ -63,31 +83,31 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
|
63
83
|
|
|
64
84
|
exports.getReconnectIdForAuthenticatedChat = getReconnectIdForAuthenticatedChat;
|
|
65
85
|
|
|
66
|
-
const handleUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
|
|
67
|
-
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
86
|
+
const handleUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, isReconnectEnabled, reconnectId, initStartChat, redirectInSameWindow) => {
|
|
87
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, chatConfig, getAuthToken, isReconnectEnabled, reconnectId);
|
|
68
88
|
|
|
69
89
|
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
70
|
-
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
90
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
71
91
|
} else {
|
|
72
|
-
await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
|
|
92
|
+
await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
|
|
73
93
|
}
|
|
74
94
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
95
|
|
|
76
96
|
|
|
77
97
|
exports.handleUnauthenticatedReconnectChat = handleUnauthenticatedReconnectChat;
|
|
78
98
|
|
|
79
|
-
const startUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
80
|
-
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
99
|
+
const startUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, isReconnectEnabled, reconnectId, initStartChat) => {
|
|
100
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, chatConfig, getAuthToken, isReconnectEnabled, reconnectId);
|
|
81
101
|
|
|
82
102
|
if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
83
|
-
await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
|
|
103
|
+
await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
|
|
84
104
|
}
|
|
85
105
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
106
|
|
|
87
107
|
|
|
88
108
|
exports.startUnauthenticatedReconnectChat = startUnauthenticatedReconnectChat;
|
|
89
109
|
|
|
90
|
-
const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
110
|
+
const setReconnectIdAndStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
91
111
|
const startUnauthenticatedReconnectChat = {
|
|
92
112
|
eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
93
113
|
};
|
|
@@ -105,7 +125,7 @@ const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconne
|
|
|
105
125
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
106
126
|
payload: _ConversationState.ConversationState.Loading
|
|
107
127
|
});
|
|
108
|
-
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
|
|
128
|
+
await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, optionalParams);
|
|
109
129
|
};
|
|
110
130
|
|
|
111
131
|
const redirectPage = (redirectURL, redirectInSameWindow) => {
|
|
@@ -128,7 +148,7 @@ const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
|
|
|
128
148
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
149
|
|
|
130
150
|
|
|
131
|
-
const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, initStartChat) => {
|
|
151
|
+
const startNewChatEmptyRedirectionUrl = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat) => {
|
|
132
152
|
const startUnauthenticatedReconnectChat = {
|
|
133
153
|
eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
134
154
|
};
|
|
@@ -153,26 +173,26 @@ const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, in
|
|
|
153
173
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
154
174
|
payload: _ConversationState.ConversationState.Loading
|
|
155
175
|
});
|
|
156
|
-
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
176
|
+
await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter);
|
|
157
177
|
}
|
|
158
178
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
159
179
|
|
|
160
180
|
|
|
161
|
-
const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
|
|
162
|
-
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
181
|
+
const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, isReconnectEnabled, reconnectId, redirectInSameWindow) => {
|
|
182
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, chatConfig, getAuthToken, isReconnectEnabled, reconnectId);
|
|
163
183
|
|
|
164
184
|
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
165
|
-
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
185
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
166
186
|
}
|
|
167
187
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
168
188
|
|
|
169
189
|
|
|
170
190
|
exports.handleRedirectUnauthenticatedReconnectChat = handleRedirectUnauthenticatedReconnectChat;
|
|
171
191
|
|
|
172
|
-
const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
|
|
192
|
+
const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
|
|
173
193
|
if (reconnectAvailabilityResponse.redirectURL) {
|
|
174
194
|
redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
|
|
175
195
|
} else {
|
|
176
|
-
await startNewChatEmptyRedirectionUrl(chatSDK, dispatch, setAdapter, initStartChat);
|
|
196
|
+
await startNewChatEmptyRedirectionUrl(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat);
|
|
177
197
|
}
|
|
178
198
|
};
|
|
@@ -43,10 +43,6 @@ const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat)
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
|
|
46
|
-
dispatch({
|
|
47
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
48
|
-
payload: _ConversationState.ConversationState.Loading
|
|
49
|
-
});
|
|
50
46
|
dispatch({
|
|
51
47
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
52
48
|
payload: _ConversationState.ConversationState.Postchat
|