@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
|
@@ -89,16 +89,22 @@ var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useCha
|
|
|
89
89
|
|
|
90
90
|
var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDKStore"));
|
|
91
91
|
|
|
92
|
+
var _ActivityStreamHandler = require("../common/ActivityStreamHandler");
|
|
93
|
+
|
|
94
|
+
var _defaultCacheManager = require("../../../common/storage/default/defaultCacheManager");
|
|
95
|
+
|
|
96
|
+
var _defaultClientDataStoreProvider = require("../../../common/storage/default/defaultClientDataStoreProvider");
|
|
97
|
+
|
|
92
98
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
93
99
|
|
|
94
100
|
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); }
|
|
95
101
|
|
|
96
102
|
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; }
|
|
97
103
|
|
|
98
|
-
function _extends() { _extends = Object.assign
|
|
104
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
99
105
|
|
|
100
106
|
const LiveChatWidgetStateful = props => {
|
|
101
|
-
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$
|
|
107
|
+
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps14, _props$controlProps15, _props$componentOverr, _props$controlProps16, _props$componentOverr2, _props$controlProps17, _props$componentOverr3, _props$controlProps18, _props$componentOverr4, _props$controlProps19, _props$componentOverr5, _props$controlProps20, _props$componentOverr6, _props$controlProps21, _props$componentOverr7, _props$controlProps22, _props$controlProps23, _props$componentOverr8, _props$controlProps24, _props$componentOverr9, _props$controlProps25, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
102
108
|
|
|
103
109
|
const [state, dispatch] = (0, _useChatContextStore.default)(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
110
|
|
|
@@ -113,106 +119,147 @@ const LiveChatWidgetStateful = props => {
|
|
|
113
119
|
const {
|
|
114
120
|
Composer
|
|
115
121
|
} = _botframeworkWebchat.Components;
|
|
116
|
-
const canStartProactiveChat = (0, _react2.useRef)(true);
|
|
117
|
-
const canEndChat = (0, _react2.useRef)(true); // Process general styles
|
|
122
|
+
const canStartProactiveChat = (0, _react2.useRef)(true); // Process general styles
|
|
118
123
|
|
|
119
124
|
const generalStyles = {
|
|
120
125
|
root: Object.assign({}, (0, _getGeneralStylesForButton.getGeneralStylesForButton)(state), (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyles)
|
|
121
126
|
};
|
|
127
|
+
const broadcastServiceChannelName = (0, _utils.getBroadcastChannelName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.widgetId, ((_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.widgetInstanceId) ?? "");
|
|
128
|
+
(0, _omnichannelChatComponents.BroadcastServiceInitialize)(broadcastServiceChannelName);
|
|
122
129
|
_TelemetryManager.TelemetryTimers.LcwLoadToChatButtonTimer = (0, _utils.createTimer)();
|
|
123
|
-
const widgetElementId = ((_props$
|
|
130
|
+
const widgetElementId = ((_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.id) || "oc-lcw";
|
|
124
131
|
const currentMessageCountRef = (0, _react2.useRef)(0);
|
|
125
132
|
let widgetStateEventName = "";
|
|
126
133
|
|
|
127
134
|
const initiateEndChatOnBrowserUnload = () => {
|
|
128
135
|
var _DataStoreManager$cli;
|
|
129
136
|
|
|
130
|
-
|
|
137
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
138
|
+
Event: _TelemetryConstants.TelemetryEvent.BrowserUnloadEventStarted,
|
|
139
|
+
Description: "Browser unload event received."
|
|
140
|
+
});
|
|
131
141
|
|
|
132
|
-
|
|
133
|
-
//Browser close scenario/no room for PCS/so just end chat and notify agent immidiately
|
|
134
|
-
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
135
|
-
} // Clean local storage
|
|
142
|
+
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false); // Clean local storage
|
|
136
143
|
|
|
144
|
+
(_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage"); //Dispose calling instance
|
|
145
|
+
|
|
146
|
+
if (voiceVideoCallingSDK) {
|
|
147
|
+
voiceVideoCallingSDK === null || voiceVideoCallingSDK === void 0 ? void 0 : voiceVideoCallingSDK.close();
|
|
148
|
+
} //Message for clearing window[popouTab]
|
|
137
149
|
|
|
138
|
-
(_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage");
|
|
139
150
|
|
|
140
151
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
141
|
-
eventName: _TelemetryConstants.BroadcastEvent.
|
|
152
|
+
eventName: _TelemetryConstants.BroadcastEvent.ClosePopoutWindow
|
|
142
153
|
});
|
|
143
|
-
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const getStateFromCache = () => {
|
|
147
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli2;
|
|
148
|
-
|
|
149
|
-
// Getting updated state from cache
|
|
150
|
-
const widgetStateEventName = (0, _utils.getWidgetCacheId)((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) ?? "");
|
|
151
|
-
const widgetStateFromCache = (_DataStoreManager$cli2 = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli2 === void 0 ? void 0 : _DataStoreManager$cli2.getData(widgetStateEventName, "localStorage");
|
|
152
|
-
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
153
|
-
return persistedState;
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
(0, _react2.useEffect)(() => {
|
|
157
|
-
var _props$
|
|
157
|
+
var _props$controlProps4, _props$controlProps5, _props$controlProps6, _props$controlProps8, _props$chatConfig, _props$chatConfig$Cha, _props$controlProps9, _props$reconnectChatP, _props$chatConfig2, _props$chatConfig2$Li, _props$reconnectChatP4, _state$domainStates;
|
|
158
|
+
|
|
159
|
+
// Add default localStorage support for widget
|
|
160
|
+
if (props.contextDataStore === undefined) {
|
|
161
|
+
var _chatSDK$omnichannelC2, _chatSDK$omnichannelC3, _props$controlProps3;
|
|
162
|
+
|
|
163
|
+
(0, _defaultCacheManager.registerBroadcastServiceForLocalStorage)(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 === null || props === void 0 ? void 0 : (_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.widgetInstanceId) ?? "");
|
|
164
|
+
_DataStoreManager.DataStoreManager.clientDataStore = (0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)();
|
|
165
|
+
} else {
|
|
166
|
+
_DataStoreManager.DataStoreManager.clientDataStore = props.contextDataStore;
|
|
167
|
+
}
|
|
158
168
|
|
|
159
169
|
(0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
|
|
160
170
|
(0, _createInternetConnectionChangeHandler.createInternetConnectionChangeHandler)();
|
|
161
|
-
_DataStoreManager.DataStoreManager.clientDataStore = props.contextDataStore ?? undefined;
|
|
162
171
|
dispatch({
|
|
163
172
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_ELEMENT_ID,
|
|
164
173
|
payload: widgetElementId
|
|
165
174
|
});
|
|
166
175
|
dispatch({
|
|
167
176
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SKIP_CHAT_BUTTON_RENDERING,
|
|
168
|
-
payload: ((_props$
|
|
177
|
+
payload: ((_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.skipChatButtonRendering) || false
|
|
169
178
|
});
|
|
170
179
|
dispatch({
|
|
171
180
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
172
181
|
payload: false
|
|
173
182
|
});
|
|
183
|
+
|
|
184
|
+
if ((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.widgetInstanceId && !(0, _utils.isNullOrEmptyString)((_props$controlProps6 = props.controlProps) === null || _props$controlProps6 === void 0 ? void 0 : _props$controlProps6.widgetInstanceId)) {
|
|
185
|
+
var _props$controlProps7;
|
|
186
|
+
|
|
187
|
+
dispatch({
|
|
188
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID,
|
|
189
|
+
payload: (_props$controlProps7 = props.controlProps) === null || _props$controlProps7 === void 0 ? void 0 : _props$controlProps7.widgetInstanceId
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
174
193
|
(0, _initCallingSdk.initCallingSdk)(chatSDK, setVoiceVideoCallingSDK).then(sdkCreated => {
|
|
175
194
|
sdkCreated && dispatch({
|
|
176
195
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
177
196
|
payload: true
|
|
178
197
|
});
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
if (!((_props$controlProps3 = props.controlProps) !== null && _props$controlProps3 !== void 0 && _props$controlProps3.skipChatButtonRendering) && (_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
|
|
182
|
-
var _props$reconnectChatP2;
|
|
198
|
+
}); // Initialize global dir
|
|
183
199
|
|
|
184
|
-
|
|
185
|
-
} // Initialize global dir
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const globalDir = ((_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.dir) ?? (0, _utils.getLocaleDirection)((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Cha = _props$chatConfig.ChatWidgetLanguage) === null || _props$chatConfig$Cha === void 0 ? void 0 : _props$chatConfig$Cha.msdyn_localeid);
|
|
200
|
+
const globalDir = ((_props$controlProps8 = props.controlProps) === null || _props$controlProps8 === void 0 ? void 0 : _props$controlProps8.dir) ?? (0, _utils.getLocaleDirection)((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Cha = _props$chatConfig.ChatWidgetLanguage) === null || _props$chatConfig$Cha === void 0 ? void 0 : _props$chatConfig$Cha.msdyn_localeid);
|
|
189
201
|
dispatch({
|
|
190
202
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_GLOBAL_DIR,
|
|
191
203
|
payload: globalDir
|
|
192
204
|
});
|
|
193
205
|
|
|
194
|
-
if ((
|
|
206
|
+
if (!((_props$controlProps9 = props.controlProps) !== null && _props$controlProps9 !== void 0 && _props$controlProps9.skipChatButtonRendering) && (_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
|
|
207
|
+
var _props$reconnectChatP2, _props$reconnectChatP3;
|
|
208
|
+
|
|
209
|
+
(0, _reconnectChatHelper.startUnauthenticatedReconnectChat)(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.isReconnectEnabled, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.reconnectId, _startChat.initStartChat);
|
|
210
|
+
return;
|
|
211
|
+
} // Checks if reconnectId is present for auth chat. If it is present, then it shows reconnect chat pane,
|
|
212
|
+
// where customer can choose to continue previous conversation or start new conversation
|
|
213
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
const isAuthenticationSettingsEnabled = (_props$chatConfig2 = props.chatConfig) !== null && _props$chatConfig2 !== void 0 && (_props$chatConfig2$Li = _props$chatConfig2.LiveChatConfigAuthSettings) !== null && _props$chatConfig2$Li !== void 0 && _props$chatConfig2$Li.msdyn_javascriptclientfunction ? true : false;
|
|
217
|
+
|
|
218
|
+
if (!state.appStates.skipChatButtonRendering && state.appStates.conversationState === _ConversationState.ConversationState.Active && isAuthenticationSettingsEnabled === true && (_props$reconnectChatP4 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP4 !== void 0 && _props$reconnectChatP4.isReconnectEnabled) {
|
|
219
|
+
(0, _reconnectChatHelper.getReconnectIdForAuthenticatedChat)(props, chatSDK).then(authReconnectId => {
|
|
220
|
+
if (authReconnectId && !state.appStates.reconnectId) {
|
|
221
|
+
dispatch({
|
|
222
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
223
|
+
payload: authReconnectId
|
|
224
|
+
});
|
|
225
|
+
dispatch({
|
|
226
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
227
|
+
payload: _ConversationState.ConversationState.ReconnectChat
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (!state.appStates.skipChatButtonRendering && !(0, _utils.isUndefinedOrEmpty)((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext) && state.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
195
235
|
var _state$domainStates2;
|
|
196
236
|
|
|
197
237
|
const optionalParams = {
|
|
198
238
|
liveChatContext: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
|
|
199
239
|
};
|
|
200
|
-
(0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams);
|
|
201
|
-
|
|
240
|
+
(0, _startChat.initStartChat)(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams);
|
|
241
|
+
return;
|
|
242
|
+
} // All other case should show start chat button, skipChatButtonRendering will take care of it own
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
dispatch({
|
|
246
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
247
|
+
payload: _ConversationState.ConversationState.Closed
|
|
248
|
+
});
|
|
202
249
|
}, []); // useEffect for when skip chat button rendering
|
|
203
250
|
|
|
204
251
|
(0, _react2.useEffect)(() => {
|
|
205
252
|
if (state.appStates.skipChatButtonRendering) {
|
|
206
|
-
var _props$
|
|
253
|
+
var _props$reconnectChatP5;
|
|
207
254
|
|
|
208
255
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
209
256
|
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
210
257
|
});
|
|
211
258
|
|
|
212
|
-
if ((_props$
|
|
213
|
-
var _props$
|
|
259
|
+
if ((_props$reconnectChatP5 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP5 !== void 0 && _props$reconnectChatP5.reconnectId && !state.appStates.reconnectId) {
|
|
260
|
+
var _props$reconnectChatP6, _props$reconnectChatP7, _props$reconnectChatP8;
|
|
214
261
|
|
|
215
|
-
(0, _reconnectChatHelper.handleUnauthenticatedReconnectChat)(chatSDK, dispatch, setAdapter, (_props$
|
|
262
|
+
(0, _reconnectChatHelper.handleUnauthenticatedReconnectChat)(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, (_props$reconnectChatP6 = props.reconnectChatPaneProps) === null || _props$reconnectChatP6 === void 0 ? void 0 : _props$reconnectChatP6.isReconnectEnabled, (_props$reconnectChatP7 = props.reconnectChatPaneProps) === null || _props$reconnectChatP7 === void 0 ? void 0 : _props$reconnectChatP7.reconnectId, _startChat.initStartChat, (_props$reconnectChatP8 = props.reconnectChatPaneProps) === null || _props$reconnectChatP8 === void 0 ? void 0 : _props$reconnectChatP8.redirectInSameWindow);
|
|
216
263
|
} else {
|
|
217
264
|
(0, _reconnectChatHelper.getReconnectIdForAuthenticatedChat)(props, chatSDK).then(authReconnectId => {
|
|
218
265
|
if (authReconnectId && !state.appStates.reconnectId) {
|
|
@@ -225,17 +272,24 @@ const LiveChatWidgetStateful = props => {
|
|
|
225
272
|
payload: _ConversationState.ConversationState.ReconnectChat
|
|
226
273
|
});
|
|
227
274
|
} else {
|
|
275
|
+
var _state$domainStates3;
|
|
276
|
+
|
|
228
277
|
const chatStartedSkippingChatButtonRendering = {
|
|
229
278
|
eventName: _TelemetryConstants.BroadcastEvent.StartChatSkippingChatButtonRendering
|
|
230
279
|
};
|
|
231
280
|
|
|
232
281
|
_omnichannelChatComponents.BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
|
|
233
282
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
283
|
+
if (!(0, _utils.isUndefinedOrEmpty)((_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : _state$domainStates3.liveChatContext) && state.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
284
|
+
var _state$domainStates4;
|
|
285
|
+
|
|
286
|
+
const optionalParams = {
|
|
287
|
+
liveChatContext: (_state$domainStates4 = state.domainStates) === null || _state$domainStates4 === void 0 ? void 0 : _state$domainStates4.liveChatContext
|
|
288
|
+
};
|
|
289
|
+
(0, _startChat.initStartChat)(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams);
|
|
290
|
+
} else {
|
|
291
|
+
(0, _startChat.setPreChatAndInitiateChat)(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter);
|
|
292
|
+
}
|
|
239
293
|
}
|
|
240
294
|
});
|
|
241
295
|
}
|
|
@@ -243,7 +297,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
243
297
|
}, [state.appStates.skipChatButtonRendering]); // useEffect for when skip chat button rendering
|
|
244
298
|
|
|
245
299
|
(0, _react2.useEffect)(() => {
|
|
246
|
-
var _chatSDK$
|
|
300
|
+
var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$controlProps12;
|
|
247
301
|
|
|
248
302
|
// Add the custom context on receiving the SetCustomContext event
|
|
249
303
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
@@ -264,7 +318,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
264
318
|
Description: "Start proactive chat event received."
|
|
265
319
|
});
|
|
266
320
|
|
|
267
|
-
if (canStartProactiveChat.current) {
|
|
321
|
+
if (canStartProactiveChat.current === true) {
|
|
268
322
|
var _msg$payload, _msg$payload2, _msg$payload3;
|
|
269
323
|
|
|
270
324
|
(0, _startProactiveChat.startProactiveChat)(dispatch, msg === null || msg === void 0 ? void 0 : (_msg$payload = msg.payload) === null || _msg$payload === void 0 ? void 0 : _msg$payload.notificationConfig, msg === null || msg === void 0 ? void 0 : (_msg$payload2 = msg.payload) === null || _msg$payload2 === void 0 ? void 0 : _msg$payload2.enablePreChat, msg === null || msg === void 0 ? void 0 : (_msg$payload3 = msg.payload) === null || _msg$payload3 === void 0 ? void 0 : _msg$payload3.inNewWindow);
|
|
@@ -278,31 +332,39 @@ const LiveChatWidgetStateful = props => {
|
|
|
278
332
|
|
|
279
333
|
|
|
280
334
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(() => {
|
|
335
|
+
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$controlProps10;
|
|
336
|
+
|
|
281
337
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
282
338
|
Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
|
|
283
339
|
Description: "Start chat event received."
|
|
284
340
|
});
|
|
285
341
|
|
|
286
|
-
const persistedState = getStateFromCache();
|
|
342
|
+
const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC5 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC5 === void 0 ? void 0 : _chatSDK$omnichannelC5.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps10 = props.controlProps) === null || _props$controlProps10 === void 0 ? void 0 : _props$controlProps10.widgetInstanceId) ?? ""); // Chat not found in cache
|
|
287
343
|
|
|
288
|
-
if (persistedState
|
|
289
|
-
// Embedded mode
|
|
344
|
+
if (persistedState === undefined) {
|
|
290
345
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
291
346
|
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
292
347
|
});
|
|
293
348
|
|
|
294
349
|
(0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
298
|
-
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
299
|
-
});
|
|
350
|
+
return;
|
|
351
|
+
} // Chat exist in cache
|
|
300
352
|
|
|
301
|
-
|
|
302
|
-
|
|
353
|
+
|
|
354
|
+
if (persistedState) {
|
|
303
355
|
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4;
|
|
304
356
|
|
|
305
|
-
//
|
|
357
|
+
// Only initiate new chat if widget state in cache in one of the followings
|
|
358
|
+
if (persistedState.appStates.conversationState === _ConversationState.ConversationState.Closed || persistedState.appStates.conversationState === _ConversationState.ConversationState.InActive || persistedState.appStates.conversationState === _ConversationState.ConversationState.Postchat) {
|
|
359
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
360
|
+
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
(0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
364
|
+
return;
|
|
365
|
+
} // If minimized, maximize the chat
|
|
366
|
+
|
|
367
|
+
|
|
306
368
|
dispatch({
|
|
307
369
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
308
370
|
payload: false
|
|
@@ -320,55 +382,43 @@ const LiveChatWidgetStateful = props => {
|
|
|
320
382
|
|
|
321
383
|
|
|
322
384
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
323
|
-
if (
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
const
|
|
328
|
-
|
|
385
|
+
if (state.appStates.skipChatButtonRendering !== true) {
|
|
386
|
+
var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$controlProps11;
|
|
387
|
+
|
|
388
|
+
// This is to ensure to get latest state from cache in multitab
|
|
389
|
+
const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
390
|
+
|
|
391
|
+
if (persistedState && persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
392
|
+
(0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
393
|
+
} else {
|
|
394
|
+
const skipEndChatSDK = true;
|
|
395
|
+
const skipCloseChat = false;
|
|
396
|
+
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
|
|
397
|
+
}
|
|
329
398
|
}
|
|
330
399
|
|
|
331
400
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
332
401
|
eventName: _TelemetryConstants.BroadcastEvent.CloseChat
|
|
333
402
|
});
|
|
334
|
-
});
|
|
403
|
+
}); // End chat on browser unload
|
|
404
|
+
|
|
335
405
|
|
|
336
406
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChatOnBrowserUnload).subscribe(() => {
|
|
337
407
|
initiateEndChatOnBrowserUnload();
|
|
338
|
-
}); // reset proactive chat params
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.ResetProactiveChatParams).subscribe(async () => {
|
|
342
|
-
dispatch({
|
|
343
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
344
|
-
payload: {
|
|
345
|
-
proactiveChatBodyTitle: "",
|
|
346
|
-
proactiveChatEnablePrechat: false,
|
|
347
|
-
proactiveChatInNewWindow: false
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
408
|
}); // Listen to end chat event from other tabs
|
|
351
409
|
|
|
352
410
|
|
|
353
|
-
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$
|
|
411
|
+
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC8 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC8 === void 0 ? void 0 : _chatSDK$omnichannelC8.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC9 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC9 === void 0 ? void 0 : _chatSDK$omnichannelC9.widgetId, ((_props$controlProps12 = props.controlProps) === null || _props$controlProps12 === void 0 ? void 0 : _props$controlProps12.widgetInstanceId) ?? "");
|
|
354
412
|
|
|
355
413
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
356
414
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
357
|
-
|
|
358
|
-
|
|
415
|
+
return;
|
|
416
|
+
}); // When conversation ended by agent
|
|
359
417
|
|
|
360
|
-
window.addEventListener("beforeunload", () => {
|
|
361
|
-
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
362
|
-
Event: _TelemetryConstants.TelemetryEvent.WindowClosed,
|
|
363
|
-
Description: "Closed window."
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
(0, _disposeTelemetryLoggers.disposeTelemetryLoggers)();
|
|
367
|
-
});
|
|
368
418
|
|
|
369
419
|
if (state.appStates.conversationEndedByAgent) {
|
|
370
420
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
|
|
371
|
-
} //Listen to WidgetSize
|
|
421
|
+
} //Listen to WidgetSize, used for minimize to maximize
|
|
372
422
|
|
|
373
423
|
|
|
374
424
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName("WidgetSize").subscribe(msg => {
|
|
@@ -377,25 +427,24 @@ const LiveChatWidgetStateful = props => {
|
|
|
377
427
|
payload: msg === null || msg === void 0 ? void 0 : msg.payload
|
|
378
428
|
});
|
|
379
429
|
});
|
|
430
|
+
|
|
431
|
+
return () => {
|
|
432
|
+
(0, _disposeTelemetryLoggers.disposeTelemetryLoggers)();
|
|
433
|
+
};
|
|
380
434
|
}, []);
|
|
381
435
|
(0, _react2.useEffect)(() => {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
385
|
-
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
|
|
386
|
-
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
387
|
-
eventName: _TelemetryConstants.BroadcastEvent.NewMessageNotification
|
|
388
|
-
});
|
|
389
|
-
});
|
|
390
|
-
} // Track the message count
|
|
391
|
-
|
|
392
|
-
|
|
436
|
+
// On new message
|
|
393
437
|
if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
394
438
|
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
|
|
439
|
+
// Track the message count
|
|
395
440
|
currentMessageCountRef.current++;
|
|
396
441
|
dispatch({
|
|
397
442
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
398
443
|
payload: currentMessageCountRef.current + 1
|
|
444
|
+
}); // New message notification
|
|
445
|
+
|
|
446
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
447
|
+
eventName: _TelemetryConstants.BroadcastEvent.NewMessageNotification
|
|
399
448
|
});
|
|
400
449
|
});
|
|
401
450
|
}
|
|
@@ -405,6 +454,12 @@ const LiveChatWidgetStateful = props => {
|
|
|
405
454
|
}, [state.appStates.conversationState, state.appStates.proactiveChatStates.proactiveChatInNewWindow]); // Reset the UnreadMessageCount when minimized is toggled and broadcast it.
|
|
406
455
|
|
|
407
456
|
(0, _react2.useEffect)(() => {
|
|
457
|
+
if (state.appStates.isMinimized) {
|
|
458
|
+
_ActivityStreamHandler.ActivityStreamHandler.cork();
|
|
459
|
+
} else {
|
|
460
|
+
setTimeout(() => _ActivityStreamHandler.ActivityStreamHandler.uncork(), 500);
|
|
461
|
+
}
|
|
462
|
+
|
|
408
463
|
currentMessageCountRef.current = -1;
|
|
409
464
|
dispatch({
|
|
410
465
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
@@ -420,7 +475,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
420
475
|
}, [state.appStates.isMinimized]); // Broadcast the UnreadMessageCount state on any change.
|
|
421
476
|
|
|
422
477
|
(0, _react2.useEffect)(() => {
|
|
423
|
-
if (state.appStates.isMinimized && state.appStates.unreadMessageCount > 0) {
|
|
478
|
+
if (state.appStates.isMinimized === true && state.appStates.unreadMessageCount > 0) {
|
|
424
479
|
const customEvent = {
|
|
425
480
|
elementType: _omnichannelChatComponents.ElementType.Custom,
|
|
426
481
|
eventName: _TelemetryConstants.BroadcastEvent.UnreadMessageCount,
|
|
@@ -439,9 +494,26 @@ const LiveChatWidgetStateful = props => {
|
|
|
439
494
|
}, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]); // Publish chat widget state
|
|
440
495
|
|
|
441
496
|
(0, _react2.useEffect)(() => {
|
|
442
|
-
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic;
|
|
443
|
-
|
|
444
|
-
|
|
497
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps13;
|
|
498
|
+
|
|
499
|
+
// Only activate these windows events when conversation state is active and chat widget is in popout mode
|
|
500
|
+
// Ghost chat scenarios
|
|
501
|
+
|
|
502
|
+
/* COMMENTING THIS CODE FOR PARITY WITH OLD LCW
|
|
503
|
+
if (state.appStates.conversationState === ConversationState.Active &&
|
|
504
|
+
props.controlProps?.skipChatButtonRendering === true) {
|
|
505
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
506
|
+
|
|
507
|
+
window.onbeforeunload = function () {
|
|
508
|
+
const prompt = Constants.BrowserUnloadConfirmationMessage;
|
|
509
|
+
return prompt;
|
|
510
|
+
};
|
|
511
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
512
|
+
window.onunload = function () {
|
|
513
|
+
initiateEndChatOnBrowserUnload();
|
|
514
|
+
};
|
|
515
|
+
}*/
|
|
516
|
+
widgetStateEventName = (0, _utils.getWidgetCacheId)(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps13 = props.controlProps) === null || _props$controlProps13 === void 0 ? void 0 : _props$controlProps13.widgetInstanceId) ?? "");
|
|
445
517
|
const chatWidgetStateChangeEvent = {
|
|
446
518
|
eventName: widgetStateEventName,
|
|
447
519
|
payload: { ...state
|
|
@@ -455,7 +527,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
455
527
|
const setPostChatContextRelay = () => (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
456
528
|
|
|
457
529
|
|
|
458
|
-
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat) => (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
530
|
+
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
459
531
|
|
|
460
532
|
|
|
461
533
|
const prepareEndChatRelay = (adapter, state) => (0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
@@ -463,7 +535,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
463
535
|
const prepareStartChatRelay = () => (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
464
536
|
|
|
465
537
|
|
|
466
|
-
const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
538
|
+
const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams, persistedState);
|
|
467
539
|
|
|
468
540
|
const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
|
|
469
541
|
return /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
|
|
@@ -473,29 +545,29 @@ const LiveChatWidgetStateful = props => {
|
|
|
473
545
|
id: widgetElementId,
|
|
474
546
|
styles: generalStyles,
|
|
475
547
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
476
|
-
}, !((_props$
|
|
548
|
+
}, !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideChatButton) && !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.skipChatButtonRendering) && (0, _componentController.shouldShowChatButton)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/_react2.default.createElement(_ChatButtonStateful.default, {
|
|
477
549
|
buttonProps: props.chatButtonProps,
|
|
478
550
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
479
551
|
startChat: prepareStartChatRelay
|
|
480
|
-
})), !((_props$
|
|
552
|
+
})), !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.hideProactiveChatPane) && (0, _componentController.shouldShowProactiveChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/_react2.default.createElement(_ProactiveChatPaneStateful.default, {
|
|
481
553
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
482
554
|
startChat: prepareStartChatRelay
|
|
483
|
-
})), !((_props$
|
|
555
|
+
})), !((_props$controlProps17 = props.controlProps) !== null && _props$controlProps17 !== void 0 && _props$controlProps17.hideHeader) && (0, _componentController.shouldShowHeader)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/_react2.default.createElement(_HeaderStateful.default, {
|
|
484
556
|
headerProps: props.headerProps,
|
|
485
557
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
486
558
|
endChat: endChatRelay
|
|
487
|
-
})), !((_props$
|
|
559
|
+
})), !((_props$controlProps18 = props.controlProps) !== null && _props$controlProps18 !== void 0 && _props$controlProps18.hideLoadingPane) && (0, _componentController.shouldShowLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/_react2.default.createElement(_LoadingPaneStateful.default, props.loadingPaneProps)), !((_props$controlProps19 = props.controlProps) !== null && _props$controlProps19 !== void 0 && _props$controlProps19.hideOutOfOfficeHoursPane) && (0, _componentController.shouldShowOutOfOfficeHoursPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/_react2.default.createElement(_OOOHPaneStateful.default, props.outOfOfficeHoursPaneProps)), !((_props$controlProps20 = props.controlProps) !== null && _props$controlProps20 !== void 0 && _props$controlProps20.hideReconnectChatPane) && (0, _componentController.shouldShowReconnectChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/_react2.default.createElement(_ReconnectChatPaneStateful.default, {
|
|
488
560
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
489
561
|
initStartChat: initStartChatRelay
|
|
490
|
-
})), !((_props$
|
|
562
|
+
})), !((_props$controlProps21 = props.controlProps) !== null && _props$controlProps21 !== void 0 && _props$controlProps21.hidePreChatSurveyPane) && (0, _componentController.shouldShowPreChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PreChatSurveyPaneStateful.default, {
|
|
491
563
|
surveyProps: props.preChatSurveyPaneProps,
|
|
492
564
|
initStartChat: initStartChatRelay
|
|
493
|
-
})), !((_props$
|
|
565
|
+
})), !((_props$controlProps22 = props.controlProps) !== null && _props$controlProps22 !== void 0 && _props$controlProps22.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
|
|
494
566
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
495
|
-
}, props.callingContainerProps)), !((_props$
|
|
567
|
+
}, props.callingContainerProps)), !((_props$controlProps23 = props.controlProps) !== null && _props$controlProps23 !== void 0 && _props$controlProps23.hideWebChatContainer) && (0, _componentController.shouldShowWebChatContainer)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/_react2.default.createElement(_WebChatContainerStateful.default, props.webChatContainerProps)), !((_props$controlProps24 = props.controlProps) !== null && _props$controlProps24 !== void 0 && _props$controlProps24.hideConfirmationPane) && (0, _componentController.shouldShowConfirmationPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/_react2.default.createElement(_ConfirmationPaneStateful.default, _extends({}, confirmationPaneProps, {
|
|
496
568
|
setPostChatContext: setPostChatContextRelay,
|
|
497
569
|
prepareEndChat: prepareEndChatRelay
|
|
498
|
-
}))), !((_props$
|
|
570
|
+
}))), !((_props$controlProps25 = props.controlProps) !== null && _props$controlProps25 !== void 0 && _props$controlProps25.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, props.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), (0, _createFooter.createFooter)(props, state), (0, _componentController.shouldShowEmailTranscriptPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/_react2.default.createElement(_EmailTranscriptPaneStateful.default, props.emailTranscriptPane))));
|
|
499
571
|
};
|
|
500
572
|
|
|
501
573
|
exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
|
|
@@ -15,8 +15,6 @@ var _utils = require("../../common/utils");
|
|
|
15
15
|
|
|
16
16
|
var _ConversationState = require("../../contexts/common/ConversationState");
|
|
17
17
|
|
|
18
|
-
var _DataStoreManager = require("../../common/contextDataStore/DataStoreManager");
|
|
19
|
-
|
|
20
18
|
var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
|
|
21
19
|
|
|
22
20
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
@@ -93,14 +91,12 @@ const PreChatSurveyPaneStateful = props => {
|
|
|
93
91
|
});
|
|
94
92
|
|
|
95
93
|
try {
|
|
96
|
-
var _state$domainStates, _state$domainStates$t, _state$domainStates$t2,
|
|
94
|
+
var _state$domainStates, _state$domainStates$t, _state$domainStates$t2, _persistedState$domai, _persistedState$appSt;
|
|
97
95
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
101
|
-
let optionalParams = {};
|
|
96
|
+
const persistedState = (0, _utils.getStateFromCache)(((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$t = _state$domainStates.telemetryInternalData) === null || _state$domainStates$t === void 0 ? void 0 : _state$domainStates$t.orgId) ?? "", ((_state$domainStates$t2 = state.domainStates.telemetryInternalData) === null || _state$domainStates$t2 === void 0 ? void 0 : _state$domainStates$t2.widgetId) ?? "", state.domainStates.widgetInstanceId ?? "");
|
|
97
|
+
let optionalParams = {}; //Connect to Active chats and chat is not popout
|
|
102
98
|
|
|
103
|
-
if (persistedState
|
|
99
|
+
if (persistedState && !(0, _utils.isUndefinedOrEmpty)(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : _persistedState$domai.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt = persistedState.appStates) === null || _persistedState$appSt === void 0 ? void 0 : _persistedState$appSt.conversationState) === _ConversationState.ConversationState.Active && !state.appStates.skipChatButtonRendering) {
|
|
104
100
|
var _persistedState$domai2;
|
|
105
101
|
|
|
106
102
|
optionalParams = {
|
|
@@ -133,7 +133,7 @@ const ProactiveChatPaneStateful = props => {
|
|
|
133
133
|
});
|
|
134
134
|
},
|
|
135
135
|
...(proactiveChatProps === null || proactiveChatProps === void 0 ? void 0 : proactiveChatProps.controlProps),
|
|
136
|
-
bodyTitleText: state.appStates.proactiveChatStates.proactiveChatBodyTitle
|
|
136
|
+
bodyTitleText: state.appStates.proactiveChatStates.proactiveChatBodyTitle ? state.appStates.proactiveChatStates.proactiveChatBodyTitle : proactiveChatProps === null || proactiveChatProps === void 0 ? void 0 : (_proactiveChatProps$c = proactiveChatProps.controlProps) === null || _proactiveChatProps$c === void 0 ? void 0 : _proactiveChatProps$c.bodyTitleText
|
|
137
137
|
};
|
|
138
138
|
(0, _react.useEffect)(() => {
|
|
139
139
|
(0, _utils.setFocusOnElement)(document.getElementById(controlProps.id + "-startbutton"));
|