@microsoft/omnichannel-chat-widget 1.7.3-main.9d92cc9 → 1.7.3-main.c8bb80a

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.
@@ -48,6 +48,7 @@ const setAuthenticationIfApplicable = async (props, chatSDK) => {
48
48
  const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
49
49
  optionalParams = {}; //Resetting to ensure no stale values
50
50
  widgetInstanceId = (0, _utils.getWidgetCacheIdfromProps)(props);
51
+
51
52
  // reconnect > chat from cache
52
53
  if ((0, _reconnectChatHelper.isReconnectEnabled)(props.chatConfig) === true && !(0, _reconnectChatHelper.isPersistentEnabled)(props.chatConfig)) {
53
54
  const shouldStartChatNormally = await (0, _reconnectChatHelper.handleChatReconnect)(chatSDK, props, dispatch, setAdapter, initStartChat, state);
@@ -69,7 +70,11 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
69
70
  // Setting Proactive chat settings
70
71
  const isProactiveChat = state.appStates.conversationState === _ConversationState.ConversationState.ProactiveChat;
71
72
  const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat;
72
- await setAuthenticationIfApplicable(props, chatSDK);
73
+
74
+ // Setting auth settings to OC API to retrieve existing persistent chat session before start chat if any
75
+ if ((0, _reconnectChatHelper.isPersistentEnabled)(props.chatConfig)) {
76
+ await setAuthenticationIfApplicable(props, chatSDK);
77
+ }
73
78
 
74
79
  //Setting PreChat and intiate chat
75
80
  await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, state, props);
@@ -167,6 +172,9 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
167
172
  Description: "Widget loading started"
168
173
  });
169
174
 
175
+ // Auth token retrieval needs to happen during start chat to support pop-out chat
176
+ await setAuthenticationIfApplicable(props, chatSDK);
177
+
170
178
  //Check if chat retrieved from cache
171
179
  if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
172
180
  var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4, _persistedState$domai5;
@@ -20,7 +20,7 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
20
20
  const raiseMessageEvent = (activity, isHistoryMessage) => {
21
21
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
22
  const polyfillMessagePayloadForEvent = payload => {
23
- var _activity$conversatio, _TelemetryManager$Int;
23
+ var _activity$conversatio, _TelemetryManager$Int, _attachments;
24
24
  return {
25
25
  ...payload,
26
26
  channelData: activity === null || activity === void 0 ? void 0 : activity.channelData,
@@ -29,7 +29,9 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
29
29
  id: activity === null || activity === void 0 ? void 0 : activity.id,
30
30
  isChatComplete: false,
31
31
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
- text: activity === null || activity === void 0 ? void 0 : activity.text
32
+ text: activity === null || activity === void 0 ? void 0 : activity.text,
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+ attachment: (activity === null || activity === void 0 ? void 0 : (_attachments = activity.attachments) === null || _attachments === void 0 ? void 0 : _attachments.length) >= 1 ? activity === null || activity === void 0 ? void 0 : activity.attachments : []
33
35
  };
34
36
  };
35
37
  if ((activity === null || activity === void 0 ? void 0 : activity.type) === _Constants.Constants.message) {
@@ -43,6 +43,7 @@ const setAuthenticationIfApplicable = async (props, chatSDK) => {
43
43
  const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
44
44
  optionalParams = {}; //Resetting to ensure no stale values
45
45
  widgetInstanceId = getWidgetCacheIdfromProps(props);
46
+
46
47
  // reconnect > chat from cache
47
48
  if (isReconnectEnabled(props.chatConfig) === true && !isPersistentEnabled(props.chatConfig)) {
48
49
  const shouldStartChatNormally = await handleChatReconnect(chatSDK, props, dispatch, setAdapter, initStartChat, state);
@@ -64,7 +65,11 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
64
65
  // Setting Proactive chat settings
65
66
  const isProactiveChat = state.appStates.conversationState === ConversationState.ProactiveChat;
66
67
  const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat;
67
- await setAuthenticationIfApplicable(props, chatSDK);
68
+
69
+ // Setting auth settings to OC API to retrieve existing persistent chat session before start chat if any
70
+ if (isPersistentEnabled(props.chatConfig)) {
71
+ await setAuthenticationIfApplicable(props, chatSDK);
72
+ }
68
73
 
69
74
  //Setting PreChat and intiate chat
70
75
  await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, state, props);
@@ -160,6 +165,9 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
160
165
  Description: "Widget loading started"
161
166
  });
162
167
 
168
+ // Auth token retrieval needs to happen during start chat to support pop-out chat
169
+ await setAuthenticationIfApplicable(props, chatSDK);
170
+
163
171
  //Check if chat retrieved from cache
164
172
  if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
165
173
  var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4, _persistedState$domai5;
@@ -14,7 +14,7 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
14
14
  const raiseMessageEvent = (activity, isHistoryMessage) => {
15
15
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
16
  const polyfillMessagePayloadForEvent = payload => {
17
- var _activity$conversatio, _TelemetryManager$Int;
17
+ var _activity$conversatio, _TelemetryManager$Int, _attachments;
18
18
  return {
19
19
  ...payload,
20
20
  channelData: activity === null || activity === void 0 ? void 0 : activity.channelData,
@@ -23,7 +23,9 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
23
23
  id: activity === null || activity === void 0 ? void 0 : activity.id,
24
24
  isChatComplete: false,
25
25
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
- text: activity === null || activity === void 0 ? void 0 : activity.text
26
+ text: activity === null || activity === void 0 ? void 0 : activity.text,
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ attachment: (activity === null || activity === void 0 ? void 0 : (_attachments = activity.attachments) === null || _attachments === void 0 ? void 0 : _attachments.length) >= 1 ? activity === null || activity === void 0 ? void 0 : activity.attachments : []
27
29
  };
28
30
  };
29
31
  if ((activity === null || activity === void 0 ? void 0 : activity.type) === Constants.message) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.7.3-main.9d92cc9",
3
+ "version": "1.7.3-main.c8bb80a",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -75,7 +75,7 @@
75
75
  },
76
76
  "dependencies": {
77
77
  "@microsoft/omnichannel-chat-components": "1.1.5",
78
- "@microsoft/omnichannel-chat-sdk": "^1.9.5",
78
+ "@microsoft/omnichannel-chat-sdk": "^1.9.6",
79
79
  "abort-controller-es5": "^2.0.1",
80
80
  "dompurify": "^2.5.4",
81
81
  "markdown-it": "^12.3.2",