@microsoft/omnichannel-chat-widget 1.0.3-main.527b216 → 1.0.3-main.c925679
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/common/Constants.js +54 -1
- package/lib/cjs/common/storage/default/defaultCacheManager.js +7 -6
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +9 -7
- package/lib/cjs/common/telemetry/TelemetryConstants.js +6 -0
- package/lib/cjs/common/utils.js +27 -5
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -6
- package/lib/cjs/components/footerstateful/FooterStateful.js +1 -1
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +14 -13
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +2 -3
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +2 -1
- package/lib/cjs/components/livechatwidget/common/endChat.js +197 -99
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +29 -27
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -8
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +139 -0
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +2 -255
- package/lib/cjs/components/livechatwidget/common/startChat.js +70 -57
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +162 -100
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +2 -2
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +15 -5
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -4
- package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +8 -6
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +7 -1
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +16 -13
- package/lib/cjs/contexts/createReducer.js +13 -23
- package/lib/cjs/controller/componentController.js +2 -1
- package/lib/cjs/index.js +20 -0
- package/lib/esm/common/Constants.js +49 -0
- package/lib/esm/common/storage/default/defaultCacheManager.js +5 -4
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +9 -7
- package/lib/esm/common/telemetry/TelemetryConstants.js +6 -0
- package/lib/esm/common/utils.js +25 -4
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -6
- package/lib/esm/components/footerstateful/FooterStateful.js +1 -1
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -1
- package/lib/esm/components/headerstateful/HeaderStateful.js +14 -13
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +2 -3
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +2 -1
- package/lib/esm/components/livechatwidget/common/endChat.js +196 -99
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +29 -27
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +11 -8
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +130 -0
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -255
- package/lib/esm/components/livechatwidget/common/startChat.js +71 -58
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +164 -102
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +2 -2
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +15 -5
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -4
- package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -1
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +8 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +7 -1
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +18 -15
- package/lib/esm/contexts/createReducer.js +13 -23
- package/lib/esm/controller/componentController.js +2 -1
- package/lib/esm/index.js +4 -1
- package/lib/types/common/Constants.d.ts +21 -0
- package/lib/types/common/interfaces/IContextDataStore.d.ts +3 -3
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +2 -1
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +6 -0
- package/lib/types/common/utils.d.ts +3 -2
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +6 -0
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
- package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -6
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +3 -1
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +4 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +8 -7
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +2 -1
- package/lib/types/index.d.ts +3 -0
- package/package.json +2 -1
- package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +0 -36
- package/lib/cjs/contexts/common/ConversationEndEntity.js +0 -12
- package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +0 -30
- package/lib/esm/contexts/common/ConversationEndEntity.js +0 -5
- package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +0 -6
- package/lib/types/contexts/common/ConversationEndEntity.d.ts +0 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import { ChatSDKError, LiveWorkItemState } from "../../../common/Constants";
|
|
3
|
-
import { createTimer, getStateFromCache, isUndefinedOrEmpty } from "../../../common/utils";
|
|
3
|
+
import { createTimer, getStateFromCache, getWidgetCacheIdfromProps, isNullOrEmptyString, isUndefinedOrEmpty } from "../../../common/utils";
|
|
4
4
|
import { getAuthClientFunction, handleAuthentication } from "./authHelper";
|
|
5
5
|
import { ActivityStreamHandler } from "./ActivityStreamHandler";
|
|
6
6
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
@@ -20,21 +20,26 @@ import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
|
|
|
20
20
|
let optionalParams = {};
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
22
|
let widgetInstanceId;
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
let popoutWidgetInstanceId;
|
|
23
25
|
|
|
24
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
27
|
const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
26
|
-
var _props$controlProps;
|
|
27
28
|
optionalParams = {}; //Resetting to ensure no stale values
|
|
28
|
-
widgetInstanceId =
|
|
29
|
+
widgetInstanceId = getWidgetCacheIdfromProps(props);
|
|
29
30
|
|
|
30
31
|
// reconnect > chat from cache
|
|
31
32
|
await handleChatReconnect(chatSDK, props, dispatch, setAdapter, initStartChat, state);
|
|
32
|
-
|
|
33
33
|
// If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
|
|
34
34
|
if (state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.ReconnectChat) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
// Check if there is any active popout chats in cache
|
|
39
|
+
if (await canStartPopoutChat(props)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
38
43
|
// Can connect to existing chat session
|
|
39
44
|
if (await canConnectToExistingChat(props, chatSDK, state, dispatch, setAdapter)) {
|
|
40
45
|
return;
|
|
@@ -45,19 +50,12 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
45
50
|
const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat;
|
|
46
51
|
|
|
47
52
|
//Setting PreChat and intiate chat
|
|
48
|
-
setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, undefined, props);
|
|
53
|
+
await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, undefined, props);
|
|
49
54
|
};
|
|
50
55
|
|
|
51
56
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
57
|
const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState, state, props) => {
|
|
53
58
|
//Handle reconnect scenario
|
|
54
|
-
if (state) {
|
|
55
|
-
await handleChatReconnect(chatSDK, props, dispatch, setAdapter, initStartChat, state);
|
|
56
|
-
// If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
|
|
57
|
-
if (state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.ReconnectChat) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
59
|
|
|
62
60
|
// Getting prechat Survey Context
|
|
63
61
|
const parseToJson = false;
|
|
@@ -88,11 +86,11 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
88
86
|
|
|
89
87
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
88
|
const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persistedState) => {
|
|
91
|
-
var _props$
|
|
89
|
+
var _props$controlProps;
|
|
92
90
|
let isStartChatSuccessful = false;
|
|
93
91
|
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
94
92
|
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
95
|
-
const hideErrorUIPane = props === null || props === void 0 ? void 0 : (_props$
|
|
93
|
+
const hideErrorUIPane = props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.hideErrorUIPane;
|
|
96
94
|
try {
|
|
97
95
|
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
98
96
|
//Start widget load timer
|
|
@@ -106,11 +104,8 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
106
104
|
// set auth token to chat sdk before start chat
|
|
107
105
|
const authSuccess = await handleAuthentication(chatSDK, chatConfig, getAuthToken);
|
|
108
106
|
if (!authSuccess) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
payload: ConversationState.Closed
|
|
112
|
-
});
|
|
113
|
-
return;
|
|
107
|
+
// Replacing with error ui
|
|
108
|
+
throw new Error("Authentication was not successful");
|
|
114
109
|
}
|
|
115
110
|
}
|
|
116
111
|
|
|
@@ -128,7 +123,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
128
123
|
try {
|
|
129
124
|
var _window$Microsoft, _window$Microsoft$Dyn, _window$Microsoft$Dyn2, _window$Microsoft$Dyn3;
|
|
130
125
|
// Set custom context params
|
|
131
|
-
setCustomContextParams(
|
|
126
|
+
setCustomContextParams();
|
|
132
127
|
const defaultOptionalParams = {
|
|
133
128
|
sendDefaultInitContext: true,
|
|
134
129
|
isProactiveChat: !!(params !== null && params !== void 0 && params.isProactiveChat),
|
|
@@ -157,21 +152,6 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
157
152
|
payload: chatToken
|
|
158
153
|
});
|
|
159
154
|
newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe(createOnNewAdapterActivityHandler(chatToken === null || chatToken === void 0 ? void 0 : chatToken.chatId, chatToken === null || chatToken === void 0 ? void 0 : chatToken.visitorId));
|
|
160
|
-
if (persistedState) {
|
|
161
|
-
dispatch({
|
|
162
|
-
type: LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
163
|
-
payload: persistedState
|
|
164
|
-
});
|
|
165
|
-
setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
170
|
-
const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
171
|
-
dispatch({
|
|
172
|
-
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
173
|
-
payload: liveChatContext
|
|
174
|
-
});
|
|
175
155
|
|
|
176
156
|
// Set app state to Active
|
|
177
157
|
if (isStartChatSuccessful) {
|
|
@@ -186,14 +166,30 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
186
166
|
payload: ConversationState.Active
|
|
187
167
|
});
|
|
188
168
|
}
|
|
169
|
+
if (persistedState) {
|
|
170
|
+
dispatch({
|
|
171
|
+
type: LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
172
|
+
payload: persistedState
|
|
173
|
+
});
|
|
174
|
+
await setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
179
|
+
const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
180
|
+
dispatch({
|
|
181
|
+
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
182
|
+
payload: liveChatContext
|
|
183
|
+
});
|
|
189
184
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
190
185
|
Event: TelemetryEvent.WidgetLoadComplete,
|
|
191
186
|
Description: "Widget load complete",
|
|
192
187
|
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
193
188
|
});
|
|
194
189
|
|
|
195
|
-
// Set post chat context in state
|
|
196
|
-
|
|
190
|
+
// Set post chat context in state
|
|
191
|
+
// Commenting this for now as post chat context is fetched during end chat
|
|
192
|
+
await setPostChatContextAndLoadSurvey(chatSDK, dispatch);
|
|
197
193
|
|
|
198
194
|
// Updating chat session detail for telemetry
|
|
199
195
|
await updateSessionDataForTelemetry(chatSDK, dispatch);
|
|
@@ -217,12 +213,12 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
217
213
|
});
|
|
218
214
|
return;
|
|
219
215
|
}
|
|
216
|
+
dispatch({
|
|
217
|
+
type: LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
218
|
+
payload: true
|
|
219
|
+
});
|
|
220
220
|
if (!hideErrorUIPane) {
|
|
221
221
|
// Set app state to failing start chat if hideErrorUI is not turned on
|
|
222
|
-
dispatch({
|
|
223
|
-
type: LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
224
|
-
payload: true
|
|
225
|
-
});
|
|
226
222
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
227
223
|
Event: TelemetryEvent.ErrorUIPaneLoaded,
|
|
228
224
|
Description: "Error UI Pane Loaded"
|
|
@@ -258,15 +254,15 @@ const forceEndChat = async chatSDK => {
|
|
|
258
254
|
|
|
259
255
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
260
256
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
261
|
-
var
|
|
257
|
+
var _state$appStates, _persistedState$domai6, _persistedState$appSt;
|
|
262
258
|
// By pass this function in case of popout chat
|
|
263
|
-
if (state.appStates.hideStartChatButton === true) {
|
|
259
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.hideStartChatButton) === true) {
|
|
264
260
|
return false;
|
|
265
261
|
}
|
|
266
|
-
const persistedState = getStateFromCache(
|
|
262
|
+
const persistedState = getStateFromCache(getWidgetCacheIdfromProps(props));
|
|
267
263
|
|
|
268
264
|
//Connect to only active chat session
|
|
269
|
-
if (persistedState && !isUndefinedOrEmpty(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai6 = persistedState.domainStates) === null || _persistedState$domai6 === void 0 ? void 0 : _persistedState$domai6.liveChatContext)) {
|
|
265
|
+
if (persistedState && !isUndefinedOrEmpty(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai6 = persistedState.domainStates) === null || _persistedState$domai6 === void 0 ? void 0 : _persistedState$domai6.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt = persistedState.appStates) === null || _persistedState$appSt === void 0 ? void 0 : _persistedState$appSt.conversationState) === ConversationState.Active) {
|
|
270
266
|
var _persistedState$domai7;
|
|
271
267
|
dispatch({
|
|
272
268
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
@@ -277,16 +273,15 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
277
273
|
};
|
|
278
274
|
await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
|
|
279
275
|
return true;
|
|
280
|
-
} else {
|
|
281
|
-
return false;
|
|
282
276
|
}
|
|
277
|
+
return false;
|
|
283
278
|
};
|
|
284
279
|
|
|
285
280
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
286
|
-
const setCustomContextParams =
|
|
287
|
-
var
|
|
281
|
+
const setCustomContextParams = () => {
|
|
282
|
+
var _persistedState$domai8;
|
|
288
283
|
// Add custom context only for unauthenticated chat
|
|
289
|
-
const persistedState = getStateFromCache(
|
|
284
|
+
const persistedState = getStateFromCache(widgetInstanceId);
|
|
290
285
|
if (!isUndefinedOrEmpty(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai8 = persistedState.domainStates) === null || _persistedState$domai8 === void 0 ? void 0 : _persistedState$domai8.customContext)) {
|
|
291
286
|
var _persistedState$domai9, _persistedState$domai10;
|
|
292
287
|
if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai9 = persistedState.domainStates.liveChatConfig) !== null && _persistedState$domai9 !== void 0 && _persistedState$domai9.LiveChatConfigAuthSettings) {
|
|
@@ -304,25 +299,43 @@ const setCustomContextParams = chatSDK => {
|
|
|
304
299
|
});
|
|
305
300
|
}
|
|
306
301
|
};
|
|
302
|
+
const canStartPopoutChat = async props => {
|
|
303
|
+
if (props.allowSdkChatSupport === false) {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
popoutWidgetInstanceId = getWidgetCacheIdfromProps(props, true);
|
|
307
|
+
if (!isNullOrEmptyString(popoutWidgetInstanceId)) {
|
|
308
|
+
var _persistedState$domai11, _persistedState$appSt2;
|
|
309
|
+
const persistedState = getStateFromCache(popoutWidgetInstanceId);
|
|
310
|
+
if (persistedState && !isUndefinedOrEmpty(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai11 = persistedState.domainStates) === null || _persistedState$domai11 === void 0 ? void 0 : _persistedState$domai11.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt2 = persistedState.appStates) === null || _persistedState$appSt2 === void 0 ? void 0 : _persistedState$appSt2.conversationState) === ConversationState.Active) {
|
|
311
|
+
// Initiate popout chat
|
|
312
|
+
BroadcastService.postMessage({
|
|
313
|
+
eventName: BroadcastEvent.InitiateStartChatInPopoutMode
|
|
314
|
+
});
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return false;
|
|
319
|
+
};
|
|
307
320
|
|
|
308
321
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
309
322
|
const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
310
323
|
var _state$domainStates, _state$domainStates$l;
|
|
311
|
-
const
|
|
324
|
+
const requestIdFromCache = (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$l = _state$domainStates.liveChatContext) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.requestId;
|
|
312
325
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
313
326
|
let conversationDetails = undefined;
|
|
314
327
|
|
|
315
|
-
//Preserve
|
|
316
|
-
const
|
|
328
|
+
//Preserve current requestId
|
|
329
|
+
const currentRequestId = chatSDK.requestId ?? "";
|
|
317
330
|
dispatch({
|
|
318
331
|
type: LiveChatWidgetActionType.SET_INITIAL_CHAT_SDK_REQUEST_ID,
|
|
319
|
-
payload:
|
|
332
|
+
payload: currentRequestId
|
|
320
333
|
});
|
|
321
334
|
try {
|
|
322
|
-
chatSDK.requestId =
|
|
335
|
+
chatSDK.requestId = requestIdFromCache;
|
|
323
336
|
conversationDetails = await chatSDK.getConversationDetails();
|
|
324
337
|
if (Object.keys(conversationDetails).length === 0) {
|
|
325
|
-
chatSDK.requestId =
|
|
338
|
+
chatSDK.requestId = currentRequestId;
|
|
326
339
|
return false;
|
|
327
340
|
}
|
|
328
341
|
if (conversationDetails.state === LiveWorkItemState.Closed || conversationDetails.state === LiveWorkItemState.WrapUp) {
|
|
@@ -330,7 +343,7 @@ const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
|
330
343
|
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
331
344
|
payload: undefined
|
|
332
345
|
});
|
|
333
|
-
chatSDK.requestId =
|
|
346
|
+
chatSDK.requestId = currentRequestId;
|
|
334
347
|
return false;
|
|
335
348
|
}
|
|
336
349
|
return true;
|
|
@@ -341,7 +354,7 @@ const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
|
341
354
|
exception: `Conversation is not valid: ${erorr}`
|
|
342
355
|
}
|
|
343
356
|
});
|
|
344
|
-
chatSDK.requestId =
|
|
357
|
+
chatSDK.requestId = currentRequestId;
|
|
345
358
|
return false;
|
|
346
359
|
}
|
|
347
360
|
};
|