@microsoft/omnichannel-chat-widget 0.1.0-main.bcfe8a3 → 0.1.0-main.cde77ea
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 +2 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +4 -0
- package/lib/cjs/common/utils.js +48 -2
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +4 -0
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +2 -2
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +9 -1
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +4 -1
- package/lib/cjs/components/livechatwidget/common/endChat.js +49 -17
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +8 -0
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +15 -15
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +124 -84
- package/lib/cjs/components/livechatwidget/interfaces/IAuthProps.js +1 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +92 -98
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -8
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +0 -1
- package/lib/cjs/controller/componentController.js +2 -2
- package/lib/esm/common/Constants.js +2 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +4 -0
- package/lib/esm/common/utils.js +36 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -0
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/esm/components/headerstateful/HeaderStateful.js +2 -2
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +9 -2
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +4 -1
- package/lib/esm/components/livechatwidget/common/endChat.js +50 -18
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +9 -2
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +17 -16
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +125 -86
- package/lib/esm/components/livechatwidget/interfaces/IAuthProps.js +1 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +92 -97
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -8
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +0 -1
- package/lib/esm/controller/componentController.js +2 -2
- package/lib/types/common/Constants.d.ts +1 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +4 -1
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -1
- package/lib/types/common/utils.d.ts +3 -0
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
- package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
- package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/interfaces/IAuthProps.d.ts +4 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.d.ts +1 -1
- package/lib/types/contexts/common/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +0 -1
- package/package.json +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ChatSDKError } from "../../../common/Constants";
|
|
2
2
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
4
|
-
import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
|
|
5
4
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
6
5
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
7
6
|
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
@@ -9,17 +8,20 @@ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
|
9
8
|
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
10
9
|
import { createAdapter } from "./createAdapter";
|
|
11
10
|
import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEventHandler";
|
|
12
|
-
import { createTimer,
|
|
11
|
+
import { createTimer, getStateFromCache, isUndefinedOrEmpty } from "../../../common/utils";
|
|
13
12
|
import { getReconnectIdForAuthenticatedChat, handleRedirectUnauthenticatedReconnectChat } from "./reconnectChatHelper";
|
|
14
13
|
import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
|
|
15
14
|
import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
|
|
16
|
-
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
17
|
-
|
|
15
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
17
|
let optionalParams = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
18
|
|
|
20
19
|
const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
21
20
|
var _props$reconnectChatP;
|
|
22
21
|
|
|
22
|
+
optionalParams = {}; //Resetting to ensure no stale values
|
|
23
|
+
// Can connect to existing chat session
|
|
24
|
+
|
|
23
25
|
if (await canConnectToExistingChat(props, chatSDK, state, dispatch, setAdapter)) {
|
|
24
26
|
return;
|
|
25
27
|
} // Redirecting if unauthenticated reconnect chat expired
|
|
@@ -28,56 +30,71 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
28
30
|
if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
|
|
29
31
|
var _props$reconnectChatP2, _props$reconnectChatP3;
|
|
30
32
|
|
|
31
|
-
await handleRedirectUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, initStartChat, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.redirectInSameWindow);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const parseToJson = false;
|
|
35
|
-
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
36
|
-
const showPrechat = state.appStates.conversationState === ConversationState.ProactiveChat ? preChatSurveyResponse && state.appStates.proactiveChatStates.proactiveChatEnablePrechat : preChatSurveyResponse; // Getting reconnectId for authenticated chat
|
|
33
|
+
await handleRedirectUnauthenticatedReconnectChat(chatSDK, props.authProps, dispatch, setAdapter, initStartChat, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.redirectInSameWindow);
|
|
34
|
+
return;
|
|
35
|
+
} // Getting reconnectId for authenticated chat
|
|
37
36
|
|
|
38
|
-
const reconnectId = await getReconnectIdForAuthenticatedChat(props, chatSDK);
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
62
|
-
payload: ConversationState.Loading
|
|
63
|
-
});
|
|
64
|
-
setCustomContextParams(props, state);
|
|
65
|
-
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
38
|
+
const reconnectId = await getReconnectIdForAuthenticatedChat(props, chatSDK);
|
|
39
|
+
|
|
40
|
+
if (reconnectId) {
|
|
41
|
+
dispatch({
|
|
42
|
+
type: LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
43
|
+
payload: reconnectId
|
|
44
|
+
});
|
|
45
|
+
dispatch({
|
|
46
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
47
|
+
payload: ConversationState.ReconnectChat
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
} // Set custom context params
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
setCustomContextParams(props, chatSDK); // Setting Proactive chat settings
|
|
54
|
+
|
|
55
|
+
const isProactiveChat = state.appStates.conversationState === ConversationState.ProactiveChat;
|
|
56
|
+
const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat; //Setting PreChat and intiate chat
|
|
57
|
+
|
|
58
|
+
setPreChatAndInitiateChat(chatSDK, props.authProps, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat);
|
|
68
59
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
60
|
|
|
70
61
|
|
|
71
|
-
const
|
|
62
|
+
const setPreChatAndInitiateChat = async (chatSDK, authProps, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState) => {
|
|
63
|
+
// Getting prechat Survey Context
|
|
64
|
+
const parseToJson = false;
|
|
65
|
+
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
66
|
+
const showPrechat = isProactiveChat ? preChatSurveyResponse && proactiveChatEnablePrechatState : preChatSurveyResponse;
|
|
67
|
+
|
|
68
|
+
if (showPrechat) {
|
|
69
|
+
dispatch({
|
|
70
|
+
type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
71
|
+
payload: preChatSurveyResponse
|
|
72
|
+
});
|
|
73
|
+
dispatch({
|
|
74
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
75
|
+
payload: ConversationState.Prechat
|
|
76
|
+
});
|
|
77
|
+
return;
|
|
78
|
+
} //Initiate start chat
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
dispatch({
|
|
82
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
83
|
+
payload: ConversationState.Loading
|
|
84
|
+
});
|
|
85
|
+
await initStartChat(chatSDK, authProps, dispatch, setAdapter);
|
|
86
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
const initStartChat = async (chatSDK, authProps, dispatch, setAdapter, params, persistedState) => {
|
|
72
90
|
try {
|
|
73
91
|
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
74
92
|
|
|
75
|
-
let isStartChatSuccessful = false;
|
|
93
|
+
let isStartChatSuccessful = false; //Check if chat retrieved from cache
|
|
76
94
|
|
|
77
95
|
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
78
96
|
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4, _persistedState$domai5;
|
|
79
97
|
|
|
80
|
-
// Broadcasting limited cached chat details
|
|
81
98
|
BroadcastService.postMessage({
|
|
82
99
|
eventName: BroadcastEvent.ChatRetrievedFromCache,
|
|
83
100
|
payload: {
|
|
@@ -88,11 +105,18 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
88
105
|
}
|
|
89
106
|
|
|
90
107
|
try {
|
|
108
|
+
//Start widget load timer
|
|
91
109
|
TelemetryTimers.WidgetLoadTimer = createTimer();
|
|
92
110
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
93
111
|
Event: TelemetryEvent.StartChatSDKCall
|
|
94
|
-
});
|
|
95
|
-
|
|
112
|
+
}); // Set optional params
|
|
113
|
+
|
|
114
|
+
optionalParams = Object.assign({}, params, optionalParams); // set auth token to chat sdk before start chat
|
|
115
|
+
|
|
116
|
+
if (authProps && authProps.setAuthTokenProviderToChatSdk) {
|
|
117
|
+
await authProps.setAuthTokenProviderToChatSdk(chatSDK, authProps.authClientFunction);
|
|
118
|
+
}
|
|
119
|
+
|
|
96
120
|
await chatSDK.startChat(optionalParams);
|
|
97
121
|
isStartChatSuccessful = true;
|
|
98
122
|
} catch (error) {
|
|
@@ -102,46 +126,51 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
102
126
|
exception: `Failed to setup startChat: ${error}`
|
|
103
127
|
}
|
|
104
128
|
});
|
|
105
|
-
isStartChatSuccessful = false;
|
|
106
|
-
|
|
129
|
+
isStartChatSuccessful = false; // 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
|
+
|
|
132
|
+
dispatch({
|
|
133
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
134
|
+
payload: ConversationState.Closed
|
|
135
|
+
});
|
|
136
|
+
return;
|
|
137
|
+
} // New adapter creation
|
|
138
|
+
|
|
107
139
|
|
|
108
140
|
const newAdapter = await createAdapter(chatSDK);
|
|
109
141
|
setAdapter(newAdapter);
|
|
110
142
|
const chatToken = await chatSDK.getChatToken();
|
|
143
|
+
dispatch({
|
|
144
|
+
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
145
|
+
payload: chatToken
|
|
146
|
+
});
|
|
111
147
|
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));
|
|
112
148
|
|
|
113
|
-
if (
|
|
114
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
115
|
-
if (chatSDK !== null && chatSDK !== void 0 && chatSDK.getVoiceVideoCalling) {
|
|
116
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
117
|
-
const chatToken = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatToken());
|
|
118
|
-
dispatch({
|
|
119
|
-
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
120
|
-
payload: chatToken
|
|
121
|
-
});
|
|
122
|
-
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
126
|
-
dispatch({
|
|
127
|
-
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
128
|
-
payload: liveChatContext
|
|
129
|
-
});
|
|
130
|
-
await setPostChatContextAndLoadSurvey(chatSDK, dispatch);
|
|
131
|
-
await updateSessionDataForTelemetry(chatSDK, dispatch); // Set app state to Active
|
|
132
|
-
|
|
133
|
-
if (isStartChatSuccessful) {
|
|
134
|
-
dispatch({
|
|
135
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
136
|
-
payload: ConversationState.Active
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
} else {
|
|
149
|
+
if (persistedState) {
|
|
140
150
|
dispatch({
|
|
141
151
|
type: LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
142
152
|
payload: persistedState
|
|
143
153
|
});
|
|
144
154
|
await setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
|
|
155
|
+
return;
|
|
156
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
160
|
+
dispatch({
|
|
161
|
+
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
162
|
+
payload: liveChatContext
|
|
163
|
+
}); // Set post chat context in state, no survey load
|
|
164
|
+
|
|
165
|
+
await setPostChatContextAndLoadSurvey(chatSDK, dispatch); // Updating chat session detail for telemetry
|
|
166
|
+
|
|
167
|
+
await updateSessionDataForTelemetry(chatSDK, dispatch); // Set app state to Active
|
|
168
|
+
|
|
169
|
+
if (isStartChatSuccessful) {
|
|
170
|
+
dispatch({
|
|
171
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
172
|
+
payload: ConversationState.Active
|
|
173
|
+
});
|
|
145
174
|
}
|
|
146
175
|
|
|
147
176
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
@@ -168,18 +197,23 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
168
197
|
payload: ConversationState.OutOfOffice
|
|
169
198
|
});
|
|
170
199
|
}
|
|
200
|
+
} finally {
|
|
201
|
+
optionalParams = {};
|
|
171
202
|
}
|
|
172
203
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
173
204
|
|
|
174
205
|
|
|
175
206
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
176
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2,
|
|
207
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _persistedState$domai6, _persistedState$appSt;
|
|
177
208
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
209
|
+
// By pass this function in case of popout chat
|
|
210
|
+
if (state.appStates.skipChatButtonRendering === true) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
181
213
|
|
|
182
|
-
|
|
214
|
+
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); //Connect to only active chat session
|
|
215
|
+
|
|
216
|
+
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) {
|
|
183
217
|
var _persistedState$domai7;
|
|
184
218
|
|
|
185
219
|
dispatch({
|
|
@@ -189,22 +223,27 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
189
223
|
const optionalParams = {
|
|
190
224
|
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
|
|
191
225
|
};
|
|
192
|
-
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
226
|
+
await initStartChat(chatSDK, props.authProps, dispatch, setAdapter, optionalParams, persistedState);
|
|
193
227
|
return true;
|
|
194
228
|
} else {
|
|
195
229
|
return false;
|
|
196
230
|
}
|
|
197
|
-
};
|
|
231
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
const setCustomContextParams = (props, chatSDK) => {
|
|
235
|
+
var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4, _props$chatConfig, _persistedState$domai8;
|
|
236
|
+
|
|
237
|
+
// Add custom context only for unauthenticated chat
|
|
238
|
+
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.widgetId);
|
|
198
239
|
|
|
199
|
-
|
|
200
|
-
|
|
240
|
+
if (!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) && !isUndefinedOrEmpty(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai8 = persistedState.domainStates) === null || _persistedState$domai8 === void 0 ? void 0 : _persistedState$domai8.customContext)) {
|
|
241
|
+
var _persistedState$domai9;
|
|
201
242
|
|
|
202
|
-
// Add custom context if any only for unauthenticated chat
|
|
203
|
-
if (!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) && (_state$domainStates = state.domainStates) !== null && _state$domainStates !== void 0 && _state$domainStates.customContext) {
|
|
204
243
|
optionalParams = Object.assign({}, optionalParams, {
|
|
205
|
-
customContext:
|
|
244
|
+
customContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai9 = persistedState.domainStates) === null || _persistedState$domai9 === void 0 ? void 0 : _persistedState$domai9.customContext
|
|
206
245
|
});
|
|
207
246
|
}
|
|
208
247
|
};
|
|
209
248
|
|
|
210
|
-
export { prepareStartChat, initStartChat };
|
|
249
|
+
export { prepareStartChat, initStartChat, setPreChatAndInitiateChat };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|