@microsoft/omnichannel-chat-widget 1.0.5-main.545bb43 → 1.0.5-main.b771061

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.
@@ -56,7 +56,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
56
56
 
57
57
  // Initiate post chat render
58
58
  if (state !== null && state !== void 0 && (_state$domainStates2 = state.domainStates) !== null && _state$domainStates2 !== void 0 && _state$domainStates2.postChatContext) {
59
- await (0, _renderSurveyHelpers.initiatePostChat)(props, conversationDetails, state, dispatch);
59
+ await (0, _renderSurveyHelpers.initiatePostChat)(props, conversationDetails, state, dispatch, postchatContext);
60
60
  return;
61
61
  }
62
62
  } catch (error) {
@@ -87,10 +87,11 @@ const embedModePostChatWorkflow = async (state, dispatch) => {
87
87
  };
88
88
 
89
89
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
90
- const initiatePostChat = async (props, conversationDetailsParam, state, dispatch) => {
90
+ const initiatePostChat = async (props, conversationDetailsParam, state, dispatch, postchatContext) => {
91
91
  var _conversationDetails;
92
92
  conversationDetails = conversationDetailsParam;
93
- await setSurveyMode(props, (_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType, state, dispatch);
93
+ const participantType = ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType) ?? postchatContext.participantType;
94
+ await setSurveyMode(props, participantType, state, dispatch);
94
95
  await renderSurvey(state, dispatch);
95
96
  };
96
97
 
@@ -142,6 +142,14 @@ const LiveChatWidgetStateful = props => {
142
142
  }
143
143
  if (isChatValid === false) {
144
144
  if (localState) {
145
+ // adding the reconnect logic for the case when customer tries to reconnect from a new browser or InPrivate browser
146
+ if ((0, _reconnectChatHelper.isReconnectEnabled)(props.chatConfig) === true) {
147
+ await (0, _reconnectChatHelper.handleChatReconnect)(chatSDK, props, dispatch, setAdapter, _startChat.initStartChat, state);
148
+ // If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
149
+ if (state.appStates.conversationState === _ConversationState.ConversationState.Active || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat) {
150
+ return;
151
+ }
152
+ }
145
153
  await (0, _startChat.setPreChatAndInitiateChat)(chatSDK, dispatch, setAdapter, undefined, undefined, localState, props);
146
154
  return;
147
155
  } else {
@@ -51,7 +51,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
51
51
 
52
52
  // Initiate post chat render
53
53
  if (state !== null && state !== void 0 && (_state$domainStates2 = state.domainStates) !== null && _state$domainStates2 !== void 0 && _state$domainStates2.postChatContext) {
54
- await initiatePostChat(props, conversationDetails, state, dispatch);
54
+ await initiatePostChat(props, conversationDetails, state, dispatch, postchatContext);
55
55
  return;
56
56
  }
57
57
  } catch (error) {
@@ -81,10 +81,11 @@ const embedModePostChatWorkflow = async (state, dispatch) => {
81
81
  };
82
82
 
83
83
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
84
- const initiatePostChat = async (props, conversationDetailsParam, state, dispatch) => {
84
+ const initiatePostChat = async (props, conversationDetailsParam, state, dispatch, postchatContext) => {
85
85
  var _conversationDetails;
86
86
  conversationDetails = conversationDetailsParam;
87
- await setSurveyMode(props, (_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType, state, dispatch);
87
+ const participantType = ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType) ?? postchatContext.participantType;
88
+ await setSurveyMode(props, participantType, state, dispatch);
88
89
  await renderSurvey(state, dispatch);
89
90
  };
90
91
 
@@ -134,6 +134,14 @@ export const LiveChatWidgetStateful = props => {
134
134
  }
135
135
  if (isChatValid === false) {
136
136
  if (localState) {
137
+ // adding the reconnect logic for the case when customer tries to reconnect from a new browser or InPrivate browser
138
+ if (isReconnectEnabled(props.chatConfig) === true) {
139
+ await handleChatReconnect(chatSDK, props, dispatch, setAdapter, initStartChat, state);
140
+ // If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
141
+ if (state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.ReconnectChat) {
142
+ return;
143
+ }
144
+ }
137
145
  await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, undefined, undefined, localState, props);
138
146
  return;
139
147
  } else {
@@ -2,7 +2,7 @@ import { Dispatch } from "react";
2
2
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
3
3
  import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
4
4
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
5
- declare const initiatePostChat: (props: ILiveChatWidgetProps, conversationDetailsParam: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
5
+ declare const initiatePostChat: (props: ILiveChatWidgetProps, conversationDetailsParam: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, postchatContext: any) => Promise<void>;
6
6
  declare const isPostChatEnabled: (props: ILiveChatWidgetProps, state: ILiveChatWidgetContext) => boolean;
7
7
  declare const getPostChatContext: (chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
8
8
  declare const setWidgetStateToInactive: (dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.0.5-main.545bb43",
3
+ "version": "1.0.5-main.b771061",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",