@microsoft/omnichannel-chat-widget 0.1.0-main.a7ac5de → 0.1.0-main.a7b2241
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/README.md +7 -34
- package/lib/cjs/assets/Icons.js +4 -2
- package/lib/cjs/common/Constants.js +7 -3
- package/lib/cjs/common/KeyCodes.js +3 -1
- package/lib/cjs/common/contextDataStore/DataStoreManager.js +3 -1
- package/lib/cjs/common/storage/default/defaultCacheManager.js +5 -3
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +15 -6
- package/lib/cjs/common/telemetry/TelemetryConstants.js +13 -0
- package/lib/cjs/common/telemetry/TelemetryHelper.js +5 -2
- package/lib/cjs/common/telemetry/TelemetryManager.js +3 -1
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +1 -1
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +6 -4
- package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +3 -1
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +139 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +3 -1
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +3 -1
- package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +3 -1
- package/lib/cjs/components/livechatwidget/common/Deferred.js +3 -1
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +66 -14
- package/lib/cjs/components/livechatwidget/common/endChat.js +23 -17
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +25 -13
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +6 -9
- package/lib/cjs/components/livechatwidget/common/startChat.js +76 -53
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +44 -38
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +22 -2
- package/lib/cjs/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +57 -0
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/common/mockadapter.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +5 -6
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +29 -28
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +5 -2
- package/lib/cjs/contexts/createReducer.js +8 -0
- package/lib/cjs/hooks/useDebounce.js +28 -0
- package/lib/cjs/hooks/useWindowDimensions.js +30 -0
- package/lib/cjs/plugins/newMessageEventHandler.js +14 -0
- package/lib/esm/assets/Icons.js +2 -1
- package/lib/esm/common/Constants.js +7 -3
- package/lib/esm/common/KeyCodes.js +3 -1
- package/lib/esm/common/contextDataStore/DataStoreManager.js +3 -1
- package/lib/esm/common/storage/default/defaultCacheManager.js +5 -3
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +15 -6
- package/lib/esm/common/telemetry/TelemetryConstants.js +13 -0
- package/lib/esm/common/telemetry/TelemetryHelper.js +5 -2
- package/lib/esm/common/telemetry/TelemetryManager.js +3 -1
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +1 -1
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
- package/lib/esm/components/headerstateful/HeaderStateful.js +6 -4
- package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +3 -1
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +134 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +3 -1
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +3 -1
- package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +3 -1
- package/lib/esm/components/livechatwidget/common/Deferred.js +3 -1
- package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +66 -14
- package/lib/esm/components/livechatwidget/common/endChat.js +23 -17
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +25 -13
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +7 -9
- package/lib/esm/components/livechatwidget/common/startChat.js +76 -53
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +45 -39
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +22 -2
- package/lib/esm/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +50 -0
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/common/mockadapter.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +5 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +29 -28
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +5 -2
- package/lib/esm/contexts/createReducer.js +8 -0
- package/lib/esm/hooks/useDebounce.js +22 -0
- package/lib/esm/hooks/useWindowDimensions.js +23 -0
- package/lib/esm/plugins/newMessageEventHandler.js +14 -0
- package/lib/types/assets/Icons.d.ts +1 -0
- package/lib/types/common/Constants.d.ts +2 -0
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +1 -1
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +1 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +14 -1
- package/lib/types/common/telemetry/definitions/Contracts.d.ts +2 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +1 -0
- package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +4 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/startChat.d.ts +3 -3
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +2 -0
- package/lib/types/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +1 -1
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +29 -28
- package/lib/types/hooks/useDebounce.d.ts +3 -0
- package/lib/types/hooks/useWindowDimensions.d.ts +4 -0
- package/package.json +3 -3
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { ChatSDKError, LiveWorkItemState } from "../../../common/Constants";
|
|
2
1
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
|
+
import { ChatSDKError, LiveWorkItemState } from "../../../common/Constants";
|
|
3
|
+
import { createTimer, getStateFromCache, isUndefinedOrEmpty } from "../../../common/utils";
|
|
4
|
+
import { getAuthClientFunction, handleAuthentication } from "./authHelper";
|
|
5
|
+
import { ActivityStreamHandler } from "./ActivityStreamHandler";
|
|
6
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
3
7
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
4
8
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
5
9
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
@@ -8,13 +12,9 @@ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
|
8
12
|
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
9
13
|
import { createAdapter } from "./createAdapter";
|
|
10
14
|
import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEventHandler";
|
|
11
|
-
import {
|
|
15
|
+
import { handleChatReconnect } from "./reconnectChatHelper";
|
|
12
16
|
import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
|
|
13
17
|
import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
|
|
14
|
-
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
15
|
-
import { ActivityStreamHandler } from "./ActivityStreamHandler";
|
|
16
|
-
import { getAuthClientFunction, handleAuthentication } from "./authHelper";
|
|
17
|
-
import { handleChatReconnect } from "./reconnectChatHelper";
|
|
18
18
|
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
20
|
let optionalParams = {};
|
|
@@ -78,11 +78,19 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
78
78
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
79
79
|
payload: ConversationState.Loading
|
|
80
80
|
});
|
|
81
|
-
|
|
81
|
+
const optionalParams = {
|
|
82
|
+
isProactiveChat
|
|
83
|
+
};
|
|
84
|
+
await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
|
|
82
85
|
};
|
|
83
86
|
|
|
84
87
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
|
-
const initStartChat = async (chatSDK,
|
|
88
|
+
const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persistedState) => {
|
|
89
|
+
var _props$controlProps2;
|
|
90
|
+
let isStartChatSuccessful = false;
|
|
91
|
+
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
92
|
+
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
93
|
+
const hideErrorUIPane = props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.hideErrorUIPane;
|
|
86
94
|
try {
|
|
87
95
|
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
88
96
|
//Start widget load timer
|
|
@@ -96,10 +104,13 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
96
104
|
// set auth token to chat sdk before start chat
|
|
97
105
|
const authSuccess = await handleAuthentication(chatSDK, chatConfig, getAuthToken);
|
|
98
106
|
if (!authSuccess) {
|
|
107
|
+
dispatch({
|
|
108
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
109
|
+
payload: ConversationState.Closed
|
|
110
|
+
});
|
|
99
111
|
return;
|
|
100
112
|
}
|
|
101
113
|
}
|
|
102
|
-
let isStartChatSuccessful = false;
|
|
103
114
|
|
|
104
115
|
//Check if chat retrieved from cache
|
|
105
116
|
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
@@ -113,14 +124,16 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
113
124
|
});
|
|
114
125
|
}
|
|
115
126
|
try {
|
|
116
|
-
|
|
117
|
-
Event: TelemetryEvent.StartChatSDKCall
|
|
118
|
-
});
|
|
119
|
-
|
|
127
|
+
var _window$Microsoft, _window$Microsoft$Dyn, _window$Microsoft$Dyn2, _window$Microsoft$Dyn3;
|
|
120
128
|
// Set custom context params
|
|
121
129
|
setCustomContextParams(chatSDK);
|
|
122
|
-
|
|
123
|
-
|
|
130
|
+
const defaultOptionalParams = {
|
|
131
|
+
sendDefaultInitContext: true,
|
|
132
|
+
isProactiveChat: !!(params !== null && params !== void 0 && params.isProactiveChat),
|
|
133
|
+
portalContactId: (_window$Microsoft = window.Microsoft) === null || _window$Microsoft === void 0 ? void 0 : (_window$Microsoft$Dyn = _window$Microsoft.Dynamic365) === null || _window$Microsoft$Dyn === void 0 ? void 0 : (_window$Microsoft$Dyn2 = _window$Microsoft$Dyn.Portal) === null || _window$Microsoft$Dyn2 === void 0 ? void 0 : (_window$Microsoft$Dyn3 = _window$Microsoft$Dyn2.User) === null || _window$Microsoft$Dyn3 === void 0 ? void 0 : _window$Microsoft$Dyn3.contactId
|
|
134
|
+
};
|
|
135
|
+
const startChatOptionalParams = Object.assign({}, params, optionalParams, defaultOptionalParams);
|
|
136
|
+
await chatSDK.startChat(startChatOptionalParams);
|
|
124
137
|
isStartChatSuccessful = true;
|
|
125
138
|
} catch (error) {
|
|
126
139
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
@@ -130,12 +143,6 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
130
143
|
}
|
|
131
144
|
});
|
|
132
145
|
isStartChatSuccessful = false;
|
|
133
|
-
// Resetting the widget state to Closed, for recent introduction of OC rate limiting(429 Error)
|
|
134
|
-
// TODO : How to diplay a proper UI message to customer to try after sometime at this point - cool down scenario
|
|
135
|
-
dispatch({
|
|
136
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
137
|
-
payload: ConversationState.Closed
|
|
138
|
-
});
|
|
139
146
|
return;
|
|
140
147
|
}
|
|
141
148
|
|
|
@@ -164,15 +171,14 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
164
171
|
payload: liveChatContext
|
|
165
172
|
});
|
|
166
173
|
|
|
167
|
-
// Set post chat context in state, no survey load
|
|
168
|
-
setPostChatContextAndLoadSurvey(chatSDK, dispatch);
|
|
169
|
-
|
|
170
|
-
// Updating chat session detail for telemetry
|
|
171
|
-
await updateSessionDataForTelemetry(chatSDK, dispatch);
|
|
172
|
-
|
|
173
174
|
// Set app state to Active
|
|
174
175
|
if (isStartChatSuccessful) {
|
|
175
176
|
ActivityStreamHandler.uncork();
|
|
177
|
+
// Update start chat failure app state if chat loads successfully
|
|
178
|
+
dispatch({
|
|
179
|
+
type: LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
180
|
+
payload: false
|
|
181
|
+
});
|
|
176
182
|
dispatch({
|
|
177
183
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
178
184
|
payload: ConversationState.Active
|
|
@@ -183,6 +189,12 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
183
189
|
Description: "Widget load complete",
|
|
184
190
|
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
185
191
|
});
|
|
192
|
+
|
|
193
|
+
// Set post chat context in state, no survey load
|
|
194
|
+
setPostChatContextAndLoadSurvey(chatSDK, dispatch);
|
|
195
|
+
|
|
196
|
+
// Updating chat session detail for telemetry
|
|
197
|
+
await updateSessionDataForTelemetry(chatSDK, dispatch);
|
|
186
198
|
} catch (ex) {
|
|
187
199
|
TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
|
|
188
200
|
Event: TelemetryEvent.WidgetLoadFailed,
|
|
@@ -203,28 +215,56 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
203
215
|
});
|
|
204
216
|
return;
|
|
205
217
|
}
|
|
218
|
+
if (!hideErrorUIPane) {
|
|
219
|
+
// Set app state to failing start chat if hideErrorUI is not turned on
|
|
220
|
+
dispatch({
|
|
221
|
+
type: LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
222
|
+
payload: true
|
|
223
|
+
});
|
|
224
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
225
|
+
Event: TelemetryEvent.ErrorUIPaneLoaded,
|
|
226
|
+
Description: "Error UI Pane Loaded"
|
|
227
|
+
});
|
|
228
|
+
}
|
|
206
229
|
// Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
|
|
207
230
|
dispatch({
|
|
208
231
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
209
232
|
payload: ConversationState.Loading
|
|
210
233
|
});
|
|
234
|
+
|
|
235
|
+
// If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
|
|
236
|
+
// we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
|
|
237
|
+
if (isStartChatSuccessful === true) {
|
|
238
|
+
await forceEndChat(chatSDK);
|
|
239
|
+
}
|
|
211
240
|
} finally {
|
|
212
241
|
optionalParams = {};
|
|
213
242
|
widgetInstanceId = "";
|
|
214
243
|
}
|
|
215
244
|
};
|
|
216
245
|
|
|
246
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
247
|
+
const forceEndChat = async chatSDK => {
|
|
248
|
+
TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
|
|
249
|
+
Event: TelemetryEvent.WidgetLoadFailed,
|
|
250
|
+
ExceptionDetails: {
|
|
251
|
+
Exception: "SessionInit was successful, but widget load failed."
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat();
|
|
255
|
+
};
|
|
256
|
+
|
|
217
257
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
218
258
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
219
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$
|
|
259
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps3, _persistedState$domai6;
|
|
220
260
|
// By pass this function in case of popout chat
|
|
221
261
|
if (state.appStates.hideStartChatButton === true) {
|
|
222
262
|
return false;
|
|
223
263
|
}
|
|
224
|
-
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId, (props === null || props === void 0 ? void 0 : (_props$
|
|
264
|
+
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.widgetInstanceId) ?? "");
|
|
225
265
|
|
|
226
266
|
//Connect to only active chat session
|
|
227
|
-
if (persistedState && !isUndefinedOrEmpty(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai6 = persistedState.domainStates) === null || _persistedState$domai6 === void 0 ? void 0 : _persistedState$domai6.liveChatContext)
|
|
267
|
+
if (persistedState && !isUndefinedOrEmpty(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai6 = persistedState.domainStates) === null || _persistedState$domai6 === void 0 ? void 0 : _persistedState$domai6.liveChatContext)) {
|
|
228
268
|
var _persistedState$domai7;
|
|
229
269
|
dispatch({
|
|
230
270
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
@@ -233,7 +273,7 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
233
273
|
const optionalParams = {
|
|
234
274
|
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
|
|
235
275
|
};
|
|
236
|
-
await initStartChat(chatSDK,
|
|
276
|
+
await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
|
|
237
277
|
return true;
|
|
238
278
|
} else {
|
|
239
279
|
return false;
|
|
@@ -264,30 +304,9 @@ const setCustomContextParams = chatSDK => {
|
|
|
264
304
|
};
|
|
265
305
|
|
|
266
306
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
267
|
-
const
|
|
268
|
-
//For auth chat
|
|
269
|
-
if (props.getAuthToken) {
|
|
270
|
-
const authClientFunction = getAuthClientFunction(props.chatConfig);
|
|
271
|
-
if (authClientFunction) {
|
|
272
|
-
// set auth token to chat sdk before start chat
|
|
273
|
-
const authSuccess = await handleAuthentication(chatSDK, props.chatConfig, props.getAuthToken);
|
|
274
|
-
if (!authSuccess) {
|
|
275
|
-
return false;
|
|
276
|
-
}
|
|
277
|
-
return true;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
return true;
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
284
|
-
const checkIfConversationStillValid = async (chatSDK, props, requestId) => {
|
|
307
|
+
const checkIfConversationStillValid = async (chatSDK, props, requestId, dispatch) => {
|
|
285
308
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
286
309
|
let conversationDetails = undefined;
|
|
287
|
-
const authSucceed = await handleAuthenticationIfEnabled(chatSDK, props);
|
|
288
|
-
if (!authSucceed) {
|
|
289
|
-
return false;
|
|
290
|
-
}
|
|
291
310
|
|
|
292
311
|
//Preserve old requestId
|
|
293
312
|
const oldRequestId = chatSDK.requestId;
|
|
@@ -299,6 +318,10 @@ const checkIfConversationStillValid = async (chatSDK, props, requestId) => {
|
|
|
299
318
|
return false;
|
|
300
319
|
}
|
|
301
320
|
if (conversationDetails.state === LiveWorkItemState.Closed || conversationDetails.state === LiveWorkItemState.WrapUp) {
|
|
321
|
+
dispatch({
|
|
322
|
+
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
323
|
+
payload: undefined
|
|
324
|
+
});
|
|
302
325
|
chatSDK.requestId = oldRequestId;
|
|
303
326
|
return false;
|
|
304
327
|
}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
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); }
|
|
2
2
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
-
import { BroadcastService,
|
|
3
|
+
import { BroadcastService, BroadcastServiceInitialize, decodeComponentString } from "@microsoft/omnichannel-chat-components";
|
|
4
4
|
import { Stack } from "@fluentui/react";
|
|
5
5
|
import React, { useEffect, useRef, useState } from "react";
|
|
6
|
-
import { createTimer, getBroadcastChannelName, getLocaleDirection, getStateFromCache, getWidgetCacheId, getWidgetEndChatEventName, isNullOrEmptyString, isUndefinedOrEmpty } from "../../../common/utils";
|
|
7
6
|
import { checkIfConversationStillValid, initStartChat, prepareStartChat, setPreChatAndInitiateChat } from "../common/startChat";
|
|
7
|
+
import { createTimer, getBroadcastChannelName, getLocaleDirection, getStateFromCache, getWidgetCacheId, getWidgetEndChatEventName, isNullOrEmptyString, isUndefinedOrEmpty } from "../../../common/utils";
|
|
8
|
+
import { endChat, prepareEndChat } from "../common/endChat";
|
|
8
9
|
import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
|
|
10
|
+
import { ActivityStreamHandler } from "../common/ActivityStreamHandler";
|
|
9
11
|
import CallingContainerStateful from "../../callingcontainerstateful/CallingContainerStateful";
|
|
10
12
|
import ChatButtonStateful from "../../chatbuttonstateful/ChatButtonStateful";
|
|
11
13
|
import { Components } from "botframework-webchat";
|
|
12
14
|
import ConfirmationPaneStateful from "../../confirmationpanestateful/ConfirmationPaneStateful";
|
|
13
15
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
14
16
|
import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
|
|
17
|
+
import { Constants, E2VVOptions } from "../../../common/Constants";
|
|
15
18
|
import { ElementType } from "@microsoft/omnichannel-chat-components";
|
|
16
19
|
import EmailTranscriptPaneStateful from "../../emailtranscriptpanestateful/EmailTranscriptPaneStateful";
|
|
17
20
|
import HeaderStateful from "../../headerstateful/HeaderStateful";
|
|
@@ -28,26 +31,23 @@ import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
|
28
31
|
import WebChatContainerStateful from "../../webchatcontainerstateful/WebChatContainerStateful";
|
|
29
32
|
import { createFooter } from "../common/createFooter";
|
|
30
33
|
import { createInternetConnectionChangeHandler } from "../common/createInternetConnectionChangeHandler";
|
|
34
|
+
import { defaultClientDataStoreProvider } from "../../../common/storage/default/defaultClientDataStoreProvider";
|
|
35
|
+
import { defaultScrollBarProps } from "../common/defaultProps/defaultScrollBarProps";
|
|
31
36
|
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
32
37
|
import { disposeTelemetryLoggers } from "../common/disposeTelemetryLoggers";
|
|
33
|
-
import { endChat, prepareEndChat } from "../common/endChat";
|
|
34
38
|
import { getGeneralStylesForButton } from "../common/getGeneralStylesForButton";
|
|
35
39
|
import { initCallingSdk } from "../common/initCallingSdk";
|
|
36
40
|
import { initConfirmationPropsComposer } from "../common/initConfirmationPropsComposer";
|
|
37
41
|
import { initWebChatComposer } from "../common/initWebChatComposer";
|
|
42
|
+
import { registerBroadcastServiceForLocalStorage } from "../../../common/storage/default/defaultCacheManager";
|
|
38
43
|
import { registerTelemetryLoggers } from "../common/registerTelemetryLoggers";
|
|
39
44
|
import { setPostChatContextAndLoadSurvey } from "../common/setPostChatContextAndLoadSurvey";
|
|
40
45
|
import { startProactiveChat } from "../common/startProactiveChat";
|
|
41
46
|
import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
42
47
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
43
48
|
import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
44
|
-
import { ActivityStreamHandler } from "../common/ActivityStreamHandler";
|
|
45
|
-
import { registerBroadcastServiceForLocalStorage } from "../../../common/storage/default/defaultCacheManager";
|
|
46
|
-
import { defaultClientDataStoreProvider } from "../../../common/storage/default/defaultClientDataStoreProvider";
|
|
47
|
-
import { defaultScrollBarProps } from "../common/defaultProps/defaultScrollBarProps";
|
|
48
|
-
import { E2VVOptions } from "../../../common/Constants";
|
|
49
49
|
export const LiveChatWidgetStateful = props => {
|
|
50
|
-
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$
|
|
50
|
+
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;
|
|
51
51
|
const [state, dispatch] = useChatContextStore();
|
|
52
52
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
53
|
const [adapter, setAdapter] = useChatAdapterStore();
|
|
@@ -95,7 +95,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
95
95
|
};
|
|
96
96
|
} else {
|
|
97
97
|
activeCachedChatExist = false;
|
|
98
|
-
optionalParams =
|
|
98
|
+
optionalParams = {};
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
|
|
@@ -115,9 +115,9 @@ export const LiveChatWidgetStateful = props => {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
//Check if conversation state is not in wrapup or closed state
|
|
118
|
-
isChatValid = await checkIfConversationStillValid(chatSDK, props, (_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : (_state$domainStates3$ = _state$domainStates3.liveChatContext) === null || _state$domainStates3$ === void 0 ? void 0 : _state$domainStates3$.requestId);
|
|
118
|
+
isChatValid = await checkIfConversationStillValid(chatSDK, props, (_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : (_state$domainStates3$ = _state$domainStates3.liveChatContext) === null || _state$domainStates3$ === void 0 ? void 0 : _state$domainStates3$.requestId, dispatch);
|
|
119
119
|
if (isChatValid === true) {
|
|
120
|
-
await initStartChat(chatSDK,
|
|
120
|
+
await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
@@ -133,16 +133,22 @@ export const LiveChatWidgetStateful = props => {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
138
|
+
const setupClientDataStore = () => {
|
|
138
139
|
// Add default localStorage support for widget
|
|
139
140
|
if (props.contextDataStore === undefined) {
|
|
140
|
-
var _chatSDK$omnichannelC2, _chatSDK$omnichannelC3, _props$
|
|
141
|
-
|
|
142
|
-
DataStoreManager.clientDataStore = defaultClientDataStoreProvider();
|
|
141
|
+
var _props$controlProps3, _chatSDK$omnichannelC2, _chatSDK$omnichannelC3, _props$controlProps4;
|
|
142
|
+
const cacheTtlInMins = (props === null || props === void 0 ? void 0 : (_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.cacheTtlInMins) ?? Constants.CacheTtlInMinutes;
|
|
143
|
+
DataStoreManager.clientDataStore = defaultClientDataStoreProvider(cacheTtlInMins);
|
|
144
|
+
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$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.widgetInstanceId) ?? "", cacheTtlInMins);
|
|
143
145
|
} else {
|
|
144
146
|
DataStoreManager.clientDataStore = props.contextDataStore;
|
|
145
147
|
}
|
|
148
|
+
};
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
var _props$controlProps5, _props$controlProps6, _props$controlProps7, _props$chatConfig, _props$chatConfig$Liv, _props$controlProps9, _props$chatConfig2, _props$chatConfig2$Ch;
|
|
151
|
+
setupClientDataStore();
|
|
146
152
|
registerTelemetryLoggers(props, dispatch);
|
|
147
153
|
createInternetConnectionChangeHandler();
|
|
148
154
|
dispatch({
|
|
@@ -151,17 +157,17 @@ export const LiveChatWidgetStateful = props => {
|
|
|
151
157
|
});
|
|
152
158
|
dispatch({
|
|
153
159
|
type: LiveChatWidgetActionType.SET_START_CHAT_BUTTON_DISPLAY,
|
|
154
|
-
payload: ((_props$
|
|
160
|
+
payload: ((_props$controlProps5 = props.controlProps) === null || _props$controlProps5 === void 0 ? void 0 : _props$controlProps5.hideStartChatButton) || false
|
|
155
161
|
});
|
|
156
162
|
dispatch({
|
|
157
163
|
type: LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
158
164
|
payload: false
|
|
159
165
|
});
|
|
160
|
-
if ((_props$
|
|
161
|
-
var _props$
|
|
166
|
+
if ((_props$controlProps6 = props.controlProps) !== null && _props$controlProps6 !== void 0 && _props$controlProps6.widgetInstanceId && !isNullOrEmptyString((_props$controlProps7 = props.controlProps) === null || _props$controlProps7 === void 0 ? void 0 : _props$controlProps7.widgetInstanceId)) {
|
|
167
|
+
var _props$controlProps8;
|
|
162
168
|
dispatch({
|
|
163
169
|
type: LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID,
|
|
164
|
-
payload: (_props$
|
|
170
|
+
payload: (_props$controlProps8 = props.controlProps) === null || _props$controlProps8 === void 0 ? void 0 : _props$controlProps8.widgetInstanceId
|
|
165
171
|
});
|
|
166
172
|
}
|
|
167
173
|
if (((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.msdyn_callingoptions) !== E2VVOptions.NoCalling) {
|
|
@@ -174,7 +180,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
174
180
|
}
|
|
175
181
|
|
|
176
182
|
// Initialize global dir
|
|
177
|
-
const globalDir = ((_props$
|
|
183
|
+
const globalDir = ((_props$controlProps9 = props.controlProps) === null || _props$controlProps9 === void 0 ? void 0 : _props$controlProps9.dir) ?? getLocaleDirection((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Ch = _props$chatConfig2.ChatWidgetLanguage) === null || _props$chatConfig2$Ch === void 0 ? void 0 : _props$chatConfig2$Ch.msdyn_localeid);
|
|
178
184
|
dispatch({
|
|
179
185
|
type: LiveChatWidgetActionType.SET_GLOBAL_DIR,
|
|
180
186
|
payload: globalDir
|
|
@@ -200,7 +206,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
200
206
|
|
|
201
207
|
// useEffect for custom context
|
|
202
208
|
useEffect(() => {
|
|
203
|
-
var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$
|
|
209
|
+
var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$controlProps12;
|
|
204
210
|
// Add the custom context on receiving the SetCustomContext event
|
|
205
211
|
BroadcastService.getMessageByEventName(BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
206
212
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
@@ -230,12 +236,12 @@ export const LiveChatWidgetStateful = props => {
|
|
|
230
236
|
|
|
231
237
|
// Start chat from SDK Event
|
|
232
238
|
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(() => {
|
|
233
|
-
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$
|
|
239
|
+
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$controlProps10;
|
|
234
240
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
235
241
|
Event: TelemetryEvent.StartChatEventRecevied,
|
|
236
242
|
Description: "Start chat event received."
|
|
237
243
|
});
|
|
238
|
-
const persistedState = 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$
|
|
244
|
+
const persistedState = 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) ?? "");
|
|
239
245
|
|
|
240
246
|
// Chat not found in cache
|
|
241
247
|
if (persistedState === undefined) {
|
|
@@ -276,9 +282,9 @@ export const LiveChatWidgetStateful = props => {
|
|
|
276
282
|
// End chat
|
|
277
283
|
BroadcastService.getMessageByEventName(BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
278
284
|
if (state.appStates.hideStartChatButton === false) {
|
|
279
|
-
var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$
|
|
285
|
+
var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$controlProps11;
|
|
280
286
|
// This is to ensure to get latest state from cache in multitab
|
|
281
|
-
const persistedState = 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$
|
|
287
|
+
const persistedState = 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) ?? "");
|
|
282
288
|
if (persistedState && persistedState.appStates.conversationState === ConversationState.Active) {
|
|
283
289
|
prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
284
290
|
} else {
|
|
@@ -298,7 +304,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
298
304
|
});
|
|
299
305
|
|
|
300
306
|
// Listen to end chat event from other tabs
|
|
301
|
-
const endChatEventName = 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$
|
|
307
|
+
const endChatEventName = 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) ?? "");
|
|
302
308
|
BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
303
309
|
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
304
310
|
return;
|
|
@@ -403,7 +409,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
403
409
|
|
|
404
410
|
// Publish chat widget state
|
|
405
411
|
useEffect(() => {
|
|
406
|
-
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$
|
|
412
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps13;
|
|
407
413
|
// Only activate these windows events when conversation state is active and chat widget is in popout mode
|
|
408
414
|
// Ghost chat scenarios
|
|
409
415
|
/* COMMENTING THIS CODE FOR PARITY WITH OLD LCW
|
|
@@ -421,7 +427,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
421
427
|
};
|
|
422
428
|
}*/
|
|
423
429
|
|
|
424
|
-
widgetStateEventName = 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$
|
|
430
|
+
widgetStateEventName = 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) ?? "");
|
|
425
431
|
const chatWidgetStateChangeEvent = {
|
|
426
432
|
eventName: widgetStateEventName,
|
|
427
433
|
payload: {
|
|
@@ -457,7 +463,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
457
463
|
const prepareEndChatRelay = (adapter, state) => prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
458
464
|
const prepareStartChatRelay = () => prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
|
|
459
465
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
460
|
-
const initStartChatRelay = (optionalParams, persistedState) => initStartChat(chatSDK,
|
|
466
|
+
const initStartChatRelay = (optionalParams, persistedState) => initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
|
|
461
467
|
const confirmationPaneProps = initConfirmationPropsComposer(props);
|
|
462
468
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("style", null, `
|
|
463
469
|
::-webkit-scrollbar {
|
|
@@ -483,28 +489,28 @@ export const LiveChatWidgetStateful = props => {
|
|
|
483
489
|
id: widgetElementId,
|
|
484
490
|
styles: generalStyles,
|
|
485
491
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
486
|
-
}, !((_props$
|
|
492
|
+
}, !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideChatButton) && !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hideStartChatButton) && shouldShowChatButton(state) && (decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/React.createElement(ChatButtonStateful, {
|
|
487
493
|
buttonProps: props.chatButtonProps,
|
|
488
494
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
489
495
|
startChat: prepareStartChatRelay
|
|
490
|
-
})), !((_props$
|
|
496
|
+
})), !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.hideProactiveChatPane) && shouldShowProactiveChatPane(state) && (decodeComponentString((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/React.createElement(ProactiveChatPaneStateful, {
|
|
491
497
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
492
498
|
startChat: prepareStartChatRelay
|
|
493
|
-
})), !((_props$
|
|
499
|
+
})), !((_props$controlProps17 = props.controlProps) !== null && _props$controlProps17 !== void 0 && _props$controlProps17.hideHeader) && shouldShowHeader(state) && (decodeComponentString((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/React.createElement(HeaderStateful, {
|
|
494
500
|
headerProps: props.headerProps,
|
|
495
501
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
496
502
|
endChat: endChatRelay
|
|
497
|
-
})), !((_props$
|
|
503
|
+
})), !((_props$controlProps18 = props.controlProps) !== null && _props$controlProps18 !== void 0 && _props$controlProps18.hideLoadingPane) && shouldShowLoadingPane(state) && (decodeComponentString((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/React.createElement(LoadingPaneStateful, props.loadingPaneProps)), !((_props$controlProps19 = props.controlProps) !== null && _props$controlProps19 !== void 0 && _props$controlProps19.hideOutOfOfficeHoursPane) && shouldShowOutOfOfficeHoursPane(state) && (decodeComponentString((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/React.createElement(OutOfOfficeHoursPaneStateful, props.outOfOfficeHoursPaneProps)), !((_props$controlProps20 = props.controlProps) !== null && _props$controlProps20 !== void 0 && _props$controlProps20.hideReconnectChatPane) && shouldShowReconnectChatPane(state) && (decodeComponentString((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/React.createElement(ReconnectChatPaneStateful, {
|
|
498
504
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
499
505
|
initStartChat: initStartChatRelay
|
|
500
|
-
})), !((_props$
|
|
506
|
+
})), !((_props$controlProps21 = props.controlProps) !== null && _props$controlProps21 !== void 0 && _props$controlProps21.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && (decodeComponentString((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
|
|
501
507
|
surveyProps: props.preChatSurveyPaneProps,
|
|
502
508
|
initStartChat: initStartChatRelay
|
|
503
|
-
})), !((_props$
|
|
509
|
+
})), !((_props$controlProps22 = props.controlProps) !== null && _props$controlProps22 !== void 0 && _props$controlProps22.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
|
|
504
510
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
505
|
-
}, props.callingContainerProps)), !((_props$
|
|
511
|
+
}, props.callingContainerProps)), !((_props$controlProps23 = props.controlProps) !== null && _props$controlProps23 !== void 0 && _props$controlProps23.hideWebChatContainer) && shouldShowWebChatContainer(state) && (decodeComponentString((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/React.createElement(WebChatContainerStateful, props.webChatContainerProps)), !((_props$controlProps24 = props.controlProps) !== null && _props$controlProps24 !== void 0 && _props$controlProps24.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
|
|
506
512
|
setPostChatContext: setPostChatContextRelay,
|
|
507
513
|
prepareEndChat: prepareEndChatRelay
|
|
508
|
-
}))), !((_props$
|
|
514
|
+
}))), !((_props$controlProps25 = props.controlProps) !== null && _props$controlProps25 !== void 0 && _props$controlProps25.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, props.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), createFooter(props, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, props.emailTranscriptPane)))));
|
|
509
515
|
};
|
|
510
516
|
export default LiveChatWidgetStateful;
|
|
@@ -5,6 +5,8 @@ import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
|
|
|
5
5
|
import { defaultGeneralLoadingPaneStyleProps } from "./common/defaultStyleProps/defaultgeneralLoadingPaneStyleProps";
|
|
6
6
|
import { findAllFocusableElement } from "../../common/utils";
|
|
7
7
|
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
8
|
+
import useWindowDimensions from "../../hooks/useWindowDimensions";
|
|
9
|
+
import { errorUILoadingPaneStyleProps } from "./common/errorUIStyleProps/errorUILoadingPaneStyleProps";
|
|
8
10
|
export const LoadingPaneStateful = props => {
|
|
9
11
|
var _props$styleProps;
|
|
10
12
|
const [state] = useChatContextStore();
|
|
@@ -13,11 +15,27 @@ export const LoadingPaneStateful = props => {
|
|
|
13
15
|
...props.styleProps,
|
|
14
16
|
generalStyleProps: generalStyleProps
|
|
15
17
|
};
|
|
18
|
+
const errorUIStyleProps = {
|
|
19
|
+
...errorUILoadingPaneStyleProps
|
|
20
|
+
};
|
|
16
21
|
const controlProps = {
|
|
17
22
|
id: "oc-lcw-loading-pane",
|
|
18
23
|
dir: state.domainStates.globalDir,
|
|
19
24
|
...props.controlProps
|
|
20
25
|
};
|
|
26
|
+
const errorUIControlProps = {
|
|
27
|
+
id: "oc-lcw-alert-pane",
|
|
28
|
+
dir: state.domainStates.globalDir,
|
|
29
|
+
titleText: "Chat is failing to load.",
|
|
30
|
+
subtitleText: "Please Close the chat and try again.",
|
|
31
|
+
hideSpinner: true,
|
|
32
|
+
hideSpinnerText: true,
|
|
33
|
+
...props.controlProps
|
|
34
|
+
};
|
|
35
|
+
const {
|
|
36
|
+
height,
|
|
37
|
+
width
|
|
38
|
+
} = useWindowDimensions();
|
|
21
39
|
|
|
22
40
|
// Move focus to the first button
|
|
23
41
|
useEffect(() => {
|
|
@@ -32,8 +50,10 @@ export const LoadingPaneStateful = props => {
|
|
|
32
50
|
}, []);
|
|
33
51
|
return /*#__PURE__*/React.createElement(LoadingPane, {
|
|
34
52
|
componentOverrides: props.componentOverrides,
|
|
35
|
-
controlProps: controlProps,
|
|
36
|
-
styleProps: styleProps
|
|
53
|
+
controlProps: state.appStates.isStartChatFailing ? errorUIControlProps : controlProps,
|
|
54
|
+
styleProps: state.appStates.isStartChatFailing ? errorUIStyleProps : styleProps,
|
|
55
|
+
windowWidth: width,
|
|
56
|
+
windowHeight: height
|
|
37
57
|
});
|
|
38
58
|
};
|
|
39
59
|
export default LoadingPaneStateful;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ImageFit } from "@fluentui/react";
|
|
2
|
+
import { AlertIcon } from "../../../../assets/Icons";
|
|
3
|
+
export const errorUILoadingPaneStyleProps = {
|
|
4
|
+
generalStyleProps: {
|
|
5
|
+
position: "initial",
|
|
6
|
+
width: "100%",
|
|
7
|
+
height: "100%",
|
|
8
|
+
left: "0%",
|
|
9
|
+
top: "0%",
|
|
10
|
+
borderRadius: "0 0 4px 4px",
|
|
11
|
+
borderWidth: "0px",
|
|
12
|
+
backgroundColor: "#FFFFFF"
|
|
13
|
+
},
|
|
14
|
+
titleStyleProps: {
|
|
15
|
+
fontFamily: "'Segoe UI',Arial,sans-serif",
|
|
16
|
+
fontWeight: "normal",
|
|
17
|
+
fontSize: "18px",
|
|
18
|
+
color: "#36454F",
|
|
19
|
+
textAlign: "center",
|
|
20
|
+
display: "flex",
|
|
21
|
+
order: 2,
|
|
22
|
+
alignSelf: "auto"
|
|
23
|
+
},
|
|
24
|
+
subtitleStyleProps: {
|
|
25
|
+
fontFamily: "'Segoe UI',Arial,sans-serif",
|
|
26
|
+
fontWeight: "normal",
|
|
27
|
+
fontSize: "18px",
|
|
28
|
+
color: "#36454F",
|
|
29
|
+
textAlign: "center",
|
|
30
|
+
display: "flex",
|
|
31
|
+
order: 3,
|
|
32
|
+
alignSelf: "auto"
|
|
33
|
+
},
|
|
34
|
+
iconStyleProps: {
|
|
35
|
+
display: "flex",
|
|
36
|
+
order: 1,
|
|
37
|
+
alignSelf: "auto",
|
|
38
|
+
backgroundColor: "#FFFFFF",
|
|
39
|
+
boxShadow: "#FFFFFF 0px 0px 0px 0px",
|
|
40
|
+
margin: "0px 0px 0px 0px"
|
|
41
|
+
},
|
|
42
|
+
iconImageProps: {
|
|
43
|
+
src: AlertIcon,
|
|
44
|
+
imageFit: ImageFit.center,
|
|
45
|
+
width: "86px",
|
|
46
|
+
height: "86px",
|
|
47
|
+
shouldFadeIn: false,
|
|
48
|
+
shouldStartVisible: true
|
|
49
|
+
}
|
|
50
|
+
};
|
|
@@ -112,7 +112,7 @@ export const PreChatSurveyPaneStateful = props => {
|
|
|
112
112
|
}
|
|
113
113
|
if (current && current.tagName.toLowerCase() == HtmlAttributeNames.div && current.childElementCount > 0) {
|
|
114
114
|
const input = current.children[0].children;
|
|
115
|
-
if (input
|
|
115
|
+
if ((input === null || input === void 0 ? void 0 : input.length) > 0 && input[0].className != HtmlAttributeNames.adaptiveCardToggleInputClassName && input[0].className != HtmlAttributeNames.adaptiveCardActionSetClassName) {
|
|
116
116
|
input[0].setAttribute(HtmlAttributeNames.ariaLabel, value);
|
|
117
117
|
}
|
|
118
118
|
}
|