@microsoft/omnichannel-chat-widget 1.5.1-main.132e1c6 → 1.5.1-main.76c6a71

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.
@@ -21,6 +21,7 @@ var _newMessageEventHandler = require("../../../plugins/newMessageEventHandler")
21
21
  var _reconnectChatHelper = require("./reconnectChatHelper");
22
22
  var _setPostChatContextAndLoadSurvey = require("./setPostChatContextAndLoadSurvey");
23
23
  var _updateSessionDataForTelemetry = require("./updateSessionDataForTelemetry");
24
+ var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
24
25
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
26
  let optionalParams = {};
26
27
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -119,6 +120,12 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
119
120
  const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
120
121
  const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
121
122
  const hideErrorUIPane = props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.hideErrorUIPane;
123
+ if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === _ConversationState.ConversationState.Closed) {
124
+ // Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
125
+ chatSDK.requestId = (0, _omnichannelChatSdk.uuidv4)();
126
+ chatSDK.chatToken = {};
127
+ chatSDK.reconnectId = null;
128
+ }
122
129
  try {
123
130
  var _newAdapter$activity$, _TelemetryTimers$Widg2;
124
131
  //Start widget load timer
@@ -274,7 +281,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
274
281
  });
275
282
 
276
283
  // If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
277
- // we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
284
+ // we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
278
285
  if (isStartChatSuccessful === true) {
279
286
  await forceEndChat(chatSDK);
280
287
  }
@@ -15,6 +15,7 @@ import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEv
15
15
  import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "./reconnectChatHelper";
16
16
  import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
17
17
  import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
18
+ import { uuidv4 } from "@microsoft/omnichannel-chat-sdk";
18
19
 
19
20
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
21
  let optionalParams = {};
@@ -112,6 +113,12 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
112
113
  const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
113
114
  const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
114
115
  const hideErrorUIPane = props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.hideErrorUIPane;
116
+ if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === ConversationState.Closed) {
117
+ // Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
118
+ chatSDK.requestId = uuidv4();
119
+ chatSDK.chatToken = {};
120
+ chatSDK.reconnectId = null;
121
+ }
115
122
  try {
116
123
  var _newAdapter$activity$, _TelemetryTimers$Widg2;
117
124
  //Start widget load timer
@@ -267,7 +274,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
267
274
  });
268
275
 
269
276
  // If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
270
- // we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
277
+ // we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
271
278
  if (isStartChatSuccessful === true) {
272
279
  await forceEndChat(chatSDK);
273
280
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.5.1-main.132e1c6",
3
+ "version": "1.5.1-main.76c6a71",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",