@microsoft/omnichannel-chat-widget 0.1.0-main.21ab3ba → 0.1.0-main.23dc34f
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/common/Constants.js +2 -0
- package/lib/cjs/common/storage/default/defaultCacheManager.js +2 -2
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +15 -6
- package/lib/cjs/common/telemetry/TelemetryConstants.js +5 -0
- package/lib/cjs/common/telemetry/TelemetryHelper.js +2 -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 +4 -2
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -10
- 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 +5 -5
- package/lib/cjs/components/livechatwidget/common/startChat.js +70 -59
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +43 -37
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +8 -1
- 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/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/NotDeliveredTimestamp.js +2 -14
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +4 -2
- 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/common/Constants.js +2 -0
- package/lib/esm/common/storage/default/defaultCacheManager.js +2 -2
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +15 -6
- package/lib/esm/common/telemetry/TelemetryConstants.js +5 -0
- package/lib/esm/common/telemetry/TelemetryHelper.js +2 -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 +4 -2
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -10
- 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 +6 -5
- package/lib/esm/components/livechatwidget/common/startChat.js +70 -59
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +44 -38
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +8 -1
- 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/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/NotDeliveredTimestamp.js +2 -14
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +4 -2
- 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/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 +6 -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/startChat.d.ts +3 -3
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +1 -1
- package/lib/types/hooks/useDebounce.d.ts +3 -0
- package/lib/types/hooks/useWindowDimensions.d.ts +4 -0
- package/package.json +3 -3
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import "regenerator-runtime/runtime";
|
|
2
2
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
+
import { handleAuthentication, removeAuthTokenProvider } from "./authHelper";
|
|
4
|
+
import { isNullOrEmptyString, isNullOrUndefined } from "../../../common/utils";
|
|
3
5
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
4
6
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
5
7
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
6
8
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
7
|
-
|
|
8
|
-
import { isNullOrEmptyString, isNullOrUndefined } from "../../../common/utils";
|
|
9
|
+
|
|
9
10
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
11
|
const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initStartChat, state) => {
|
|
11
12
|
var _props$chatConfig, _props$chatConfig$Liv;
|
|
@@ -53,14 +54,14 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
|
|
|
53
54
|
const chatReconnectOptionalParams = {
|
|
54
55
|
reconnectId: (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId
|
|
55
56
|
};
|
|
57
|
+
// Get auth token for getting chat reconnect context
|
|
56
58
|
if (isAuthenticatedChat) {
|
|
57
|
-
// Get auth token for for getting chat reconnect context
|
|
58
59
|
await handleAuthentication(chatSDK, chatConfig, props.getAuthToken);
|
|
59
60
|
}
|
|
60
61
|
const reconnectChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext(chatReconnectOptionalParams));
|
|
61
62
|
if (isAuthenticatedChat) {
|
|
62
63
|
// remove auth token after reconnectId is fetched
|
|
63
|
-
//
|
|
64
|
+
// AuthToken will be reset later at start chat
|
|
64
65
|
removeAuthTokenProvider(chatSDK);
|
|
65
66
|
}
|
|
66
67
|
return reconnectChatContext;
|
|
@@ -93,7 +94,7 @@ const setReconnectIdAndStartChat = async (isAuthenticatedChat, chatSDK, props, d
|
|
|
93
94
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
94
95
|
payload: ConversationState.Loading
|
|
95
96
|
});
|
|
96
|
-
await initStartChat(chatSDK,
|
|
97
|
+
await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
|
|
97
98
|
};
|
|
98
99
|
const redirectPage = (redirectURL, redirectInSameWindow) => {
|
|
99
100
|
const redirectPageRequest = {
|
|
@@ -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,10 +124,16 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
113
124
|
});
|
|
114
125
|
}
|
|
115
126
|
try {
|
|
127
|
+
var _window$Microsoft, _window$Microsoft$Dyn, _window$Microsoft$Dyn2, _window$Microsoft$Dyn3;
|
|
116
128
|
// Set custom context params
|
|
117
129
|
setCustomContextParams(chatSDK);
|
|
118
|
-
|
|
119
|
-
|
|
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);
|
|
120
137
|
isStartChatSuccessful = true;
|
|
121
138
|
} catch (error) {
|
|
122
139
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
@@ -126,12 +143,6 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
126
143
|
}
|
|
127
144
|
});
|
|
128
145
|
isStartChatSuccessful = false;
|
|
129
|
-
// Resetting the widget state to Closed, for recent introduction of OC rate limiting(429 Error)
|
|
130
|
-
// TODO : How to diplay a proper UI message to customer to try after sometime at this point - cool down scenario
|
|
131
|
-
dispatch({
|
|
132
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
133
|
-
payload: ConversationState.Closed
|
|
134
|
-
});
|
|
135
146
|
return;
|
|
136
147
|
}
|
|
137
148
|
|
|
@@ -160,12 +171,6 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
160
171
|
payload: liveChatContext
|
|
161
172
|
});
|
|
162
173
|
|
|
163
|
-
// Set post chat context in state, no survey load
|
|
164
|
-
setPostChatContextAndLoadSurvey(chatSDK, dispatch);
|
|
165
|
-
|
|
166
|
-
// Updating chat session detail for telemetry
|
|
167
|
-
await updateSessionDataForTelemetry(chatSDK, dispatch);
|
|
168
|
-
|
|
169
174
|
// Set app state to Active
|
|
170
175
|
if (isStartChatSuccessful) {
|
|
171
176
|
ActivityStreamHandler.uncork();
|
|
@@ -184,6 +189,12 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
184
189
|
Description: "Widget load complete",
|
|
185
190
|
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
186
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);
|
|
187
198
|
} catch (ex) {
|
|
188
199
|
TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
|
|
189
200
|
Event: TelemetryEvent.WidgetLoadFailed,
|
|
@@ -204,33 +215,56 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
204
215
|
});
|
|
205
216
|
return;
|
|
206
217
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
+
}
|
|
212
229
|
// Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
|
|
213
230
|
dispatch({
|
|
214
231
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
215
232
|
payload: ConversationState.Loading
|
|
216
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
|
+
}
|
|
217
240
|
} finally {
|
|
218
241
|
optionalParams = {};
|
|
219
242
|
widgetInstanceId = "";
|
|
220
243
|
}
|
|
221
244
|
};
|
|
222
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
|
+
|
|
223
257
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
224
258
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
225
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$
|
|
259
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps3, _persistedState$domai6;
|
|
226
260
|
// By pass this function in case of popout chat
|
|
227
261
|
if (state.appStates.hideStartChatButton === true) {
|
|
228
262
|
return false;
|
|
229
263
|
}
|
|
230
|
-
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) ?? "");
|
|
231
265
|
|
|
232
266
|
//Connect to only active chat session
|
|
233
|
-
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)) {
|
|
234
268
|
var _persistedState$domai7;
|
|
235
269
|
dispatch({
|
|
236
270
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
@@ -239,7 +273,7 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
239
273
|
const optionalParams = {
|
|
240
274
|
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
|
|
241
275
|
};
|
|
242
|
-
await initStartChat(chatSDK,
|
|
276
|
+
await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
|
|
243
277
|
return true;
|
|
244
278
|
} else {
|
|
245
279
|
return false;
|
|
@@ -269,38 +303,11 @@ const setCustomContextParams = chatSDK => {
|
|
|
269
303
|
}
|
|
270
304
|
};
|
|
271
305
|
|
|
272
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
273
|
-
const handleAuthenticationIfEnabled = async (chatSDK, props) => {
|
|
274
|
-
//For auth chat
|
|
275
|
-
if (props.getAuthToken) {
|
|
276
|
-
const authClientFunction = getAuthClientFunction(props.chatConfig);
|
|
277
|
-
if (authClientFunction) {
|
|
278
|
-
// set auth token to chat sdk before start chat
|
|
279
|
-
const authSuccess = await handleAuthentication(chatSDK, props.chatConfig, props.getAuthToken);
|
|
280
|
-
if (!authSuccess) {
|
|
281
|
-
return false;
|
|
282
|
-
}
|
|
283
|
-
return true;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
return true;
|
|
287
|
-
};
|
|
288
|
-
|
|
289
306
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
290
307
|
const checkIfConversationStillValid = async (chatSDK, props, requestId, dispatch) => {
|
|
291
308
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
292
309
|
let conversationDetails = undefined;
|
|
293
310
|
|
|
294
|
-
// Show Loading screen during auth check and start chat calls
|
|
295
|
-
dispatch({
|
|
296
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
297
|
-
payload: ConversationState.Loading
|
|
298
|
-
});
|
|
299
|
-
const authSucceed = await handleAuthenticationIfEnabled(chatSDK, props);
|
|
300
|
-
if (!authSucceed) {
|
|
301
|
-
return false;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
311
|
//Preserve old requestId
|
|
305
312
|
const oldRequestId = chatSDK.requestId;
|
|
306
313
|
try {
|
|
@@ -311,6 +318,10 @@ const checkIfConversationStillValid = async (chatSDK, props, requestId, dispatch
|
|
|
311
318
|
return false;
|
|
312
319
|
}
|
|
313
320
|
if (conversationDetails.state === LiveWorkItemState.Closed || conversationDetails.state === LiveWorkItemState.WrapUp) {
|
|
321
|
+
dispatch({
|
|
322
|
+
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
323
|
+
payload: undefined
|
|
324
|
+
});
|
|
314
325
|
chatSDK.requestId = oldRequestId;
|
|
315
326
|
return false;
|
|
316
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
|
|
|
@@ -117,7 +117,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
117
117
|
//Check if conversation state is not in wrapup or closed state
|
|
118
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,7 @@ 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";
|
|
8
9
|
import { errorUILoadingPaneStyleProps } from "./common/errorUIStyleProps/errorUILoadingPaneStyleProps";
|
|
9
10
|
export const LoadingPaneStateful = props => {
|
|
10
11
|
var _props$styleProps;
|
|
@@ -31,6 +32,10 @@ export const LoadingPaneStateful = props => {
|
|
|
31
32
|
hideSpinnerText: true,
|
|
32
33
|
...props.controlProps
|
|
33
34
|
};
|
|
35
|
+
const {
|
|
36
|
+
height,
|
|
37
|
+
width
|
|
38
|
+
} = useWindowDimensions();
|
|
34
39
|
|
|
35
40
|
// Move focus to the first button
|
|
36
41
|
useEffect(() => {
|
|
@@ -46,7 +51,9 @@ export const LoadingPaneStateful = props => {
|
|
|
46
51
|
return /*#__PURE__*/React.createElement(LoadingPane, {
|
|
47
52
|
componentOverrides: props.componentOverrides,
|
|
48
53
|
controlProps: state.appStates.isStartChatFailing ? errorUIControlProps : controlProps,
|
|
49
|
-
styleProps: state.appStates.isStartChatFailing ? errorUIStyleProps : styleProps
|
|
54
|
+
styleProps: state.appStates.isStartChatFailing ? errorUIStyleProps : styleProps,
|
|
55
|
+
windowWidth: width,
|
|
56
|
+
windowHeight: height
|
|
50
57
|
});
|
|
51
58
|
};
|
|
52
59
|
export default LoadingPaneStateful;
|
|
@@ -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
|
}
|
|
@@ -51,9 +51,7 @@ export const activityStatusMiddleware = () => next => args => {
|
|
|
51
51
|
style: {
|
|
52
52
|
padding: "2px"
|
|
53
53
|
}
|
|
54
|
-
}, sendState === SendStatus.Sending && /*#__PURE__*/React.createElement(SendingTimestamp, {
|
|
55
|
-
args: args
|
|
56
|
-
}), sendState === SendStatus.SendFailed && /*#__PURE__*/React.createElement(NotDeliveredTimestamp, {
|
|
54
|
+
}, sendState === SendStatus.Sending && /*#__PURE__*/React.createElement(SendingTimestamp, null), sendState === SendStatus.SendFailed && /*#__PURE__*/React.createElement(NotDeliveredTimestamp, {
|
|
57
55
|
args: args
|
|
58
56
|
}), sendState === SendStatus.Sent && /*#__PURE__*/React.createElement(DeliveredTimestamp, {
|
|
59
57
|
args: args,
|