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

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.
@@ -11,23 +11,38 @@ var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants"
11
11
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
12
12
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
13
  const handleChatDisconnect = (props, state, setWebChatStyles) => {
14
- var _state$appStates;
15
- if (state !== null && state !== void 0 && (_state$appStates = state.appStates) !== null && _state$appStates !== void 0 && _state$appStates.chatDisconnectEventReceived) {
16
- var _state$domainStates, _state$domainStates$m, _props$webChatContain, _props$webChatContain2;
17
- const chatDisconnectMessage = (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$m = _state$domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_BANNER_CHAT_DISCONNECT) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_CHAT_DISCONNECT;
18
- if ((props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.renderingMiddlewareProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hideSendboxOnConversationEnd) !== false) {
19
- setWebChatStyles(styles => {
20
- return {
21
- ...styles,
22
- hideSendBox: true
23
- };
14
+ var _state$appStates, _state$domainStates, _state$domainStates$m, _props$webChatContain, _props$webChatContain2;
15
+ const chatDisconnectState = state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.chatDisconnectEventReceived;
16
+ const chatDisconnectMessage = (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$m = _state$domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_BANNER_CHAT_DISCONNECT) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_CHAT_DISCONNECT;
17
+ const hideSendBoxOnConversationEnd = props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.renderingMiddlewareProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hideSendboxOnConversationEnd;
18
+ switch (chatDisconnectState) {
19
+ case true:
20
+ if (hideSendBoxOnConversationEnd !== false) {
21
+ setWebChatStyles(styles => {
22
+ return {
23
+ ...styles,
24
+ hideSendBox: true
25
+ };
26
+ });
27
+ }
28
+ _NotificationHandler.NotificationHandler.notifyWarning(_NotificationScenarios.NotificationScenarios.ChatDisconnect, chatDisconnectMessage);
29
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
30
+ Event: _TelemetryConstants.TelemetryEvent.ChatDisconnectThreadEventReceived,
31
+ Description: "Chat disconnected due to timeout, left or removed."
24
32
  });
25
- }
26
- _NotificationHandler.NotificationHandler.notifyWarning(_NotificationScenarios.NotificationScenarios.ChatDisconnect, chatDisconnectMessage);
27
- _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
28
- Event: _TelemetryConstants.TelemetryEvent.ChatDisconnectThreadEventReceived,
29
- Description: "Chat disconnected due to timeout, left or removed."
30
- });
33
+ break;
34
+ case false:
35
+ if (hideSendBoxOnConversationEnd !== false) {
36
+ setWebChatStyles(styles => {
37
+ return {
38
+ ...styles,
39
+ hideSendBox: false
40
+ };
41
+ });
42
+ }
43
+ break;
44
+ default:
45
+ break;
31
46
  }
32
47
  };
33
48
  exports.handleChatDisconnect = handleChatDisconnect;
@@ -127,7 +127,13 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
127
127
  chatSDK.reconnectId = null;
128
128
  }
129
129
  try {
130
- var _newAdapter$activity$, _TelemetryTimers$Widg2;
130
+ var _state$appStates, _newAdapter$activity$, _TelemetryTimers$Widg2;
131
+ // Clear disconnect state on start chat
132
+ (state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.chatDisconnectEventReceived) && dispatch({
133
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
134
+ payload: false
135
+ });
136
+
131
137
  //Start widget load timer
132
138
  _TelemetryManager.TelemetryTimers.WidgetLoadTimer = (0, _utils.createTimer)();
133
139
  _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
@@ -305,9 +311,9 @@ const forceEndChat = async chatSDK => {
305
311
 
306
312
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
307
313
  const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
308
- var _state$appStates, _persistedState$domai6, _persistedState$appSt;
314
+ var _state$appStates2, _persistedState$domai6, _persistedState$appSt;
309
315
  // By pass this function in case of popout chat
310
- if ((state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.hideStartChatButton) === true) {
316
+ if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.hideStartChatButton) === true) {
311
317
  return false;
312
318
  }
313
319
  const persistedState = (0, _utils.getStateFromCache)((0, _utils.getWidgetCacheIdfromProps)(props));
@@ -616,9 +616,7 @@ const LiveChatWidgetStateful = props => {
616
616
 
617
617
  // Handle Chat disconnect cases
618
618
  (0, _react2.useEffect)(() => {
619
- if (state.appStates.chatDisconnectEventReceived) {
620
- (0, _chatDisconnectHelper.handleChatDisconnect)(props, state, setWebChatStyles);
621
- }
619
+ (0, _chatDisconnectHelper.handleChatDisconnect)(props, state, setWebChatStyles);
622
620
  }, [state.appStates.chatDisconnectEventReceived]);
623
621
  const initiateEndChatOnBrowserUnload = () => {
624
622
  var _DataStoreManager$cli;
@@ -5,23 +5,38 @@ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryCon
5
5
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
6
6
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
7
  const handleChatDisconnect = (props, state, setWebChatStyles) => {
8
- var _state$appStates;
9
- if (state !== null && state !== void 0 && (_state$appStates = state.appStates) !== null && _state$appStates !== void 0 && _state$appStates.chatDisconnectEventReceived) {
10
- var _state$domainStates, _state$domainStates$m, _props$webChatContain, _props$webChatContain2;
11
- const chatDisconnectMessage = (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$m = _state$domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_BANNER_CHAT_DISCONNECT) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_CHAT_DISCONNECT;
12
- if ((props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.renderingMiddlewareProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hideSendboxOnConversationEnd) !== false) {
13
- setWebChatStyles(styles => {
14
- return {
15
- ...styles,
16
- hideSendBox: true
17
- };
8
+ var _state$appStates, _state$domainStates, _state$domainStates$m, _props$webChatContain, _props$webChatContain2;
9
+ const chatDisconnectState = state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.chatDisconnectEventReceived;
10
+ const chatDisconnectMessage = (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$m = _state$domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_BANNER_CHAT_DISCONNECT) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_CHAT_DISCONNECT;
11
+ const hideSendBoxOnConversationEnd = props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.renderingMiddlewareProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hideSendboxOnConversationEnd;
12
+ switch (chatDisconnectState) {
13
+ case true:
14
+ if (hideSendBoxOnConversationEnd !== false) {
15
+ setWebChatStyles(styles => {
16
+ return {
17
+ ...styles,
18
+ hideSendBox: true
19
+ };
20
+ });
21
+ }
22
+ NotificationHandler.notifyWarning(NotificationScenarios.ChatDisconnect, chatDisconnectMessage);
23
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
24
+ Event: TelemetryEvent.ChatDisconnectThreadEventReceived,
25
+ Description: "Chat disconnected due to timeout, left or removed."
18
26
  });
19
- }
20
- NotificationHandler.notifyWarning(NotificationScenarios.ChatDisconnect, chatDisconnectMessage);
21
- TelemetryHelper.logActionEvent(LogLevel.INFO, {
22
- Event: TelemetryEvent.ChatDisconnectThreadEventReceived,
23
- Description: "Chat disconnected due to timeout, left or removed."
24
- });
27
+ break;
28
+ case false:
29
+ if (hideSendBoxOnConversationEnd !== false) {
30
+ setWebChatStyles(styles => {
31
+ return {
32
+ ...styles,
33
+ hideSendBox: false
34
+ };
35
+ });
36
+ }
37
+ break;
38
+ default:
39
+ break;
25
40
  }
26
41
  };
27
42
  export { handleChatDisconnect };
@@ -120,7 +120,13 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
120
120
  chatSDK.reconnectId = null;
121
121
  }
122
122
  try {
123
- var _newAdapter$activity$, _TelemetryTimers$Widg2;
123
+ var _state$appStates, _newAdapter$activity$, _TelemetryTimers$Widg2;
124
+ // Clear disconnect state on start chat
125
+ (state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.chatDisconnectEventReceived) && dispatch({
126
+ type: LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
127
+ payload: false
128
+ });
129
+
124
130
  //Start widget load timer
125
131
  TelemetryTimers.WidgetLoadTimer = createTimer();
126
132
  TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
@@ -297,9 +303,9 @@ const forceEndChat = async chatSDK => {
297
303
 
298
304
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
299
305
  const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
300
- var _state$appStates, _persistedState$domai6, _persistedState$appSt;
306
+ var _state$appStates2, _persistedState$domai6, _persistedState$appSt;
301
307
  // By pass this function in case of popout chat
302
- if ((state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.hideStartChatButton) === true) {
308
+ if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.hideStartChatButton) === true) {
303
309
  return false;
304
310
  }
305
311
  const persistedState = getStateFromCache(getWidgetCacheIdfromProps(props));
@@ -608,9 +608,7 @@ export const LiveChatWidgetStateful = props => {
608
608
 
609
609
  // Handle Chat disconnect cases
610
610
  useEffect(() => {
611
- if (state.appStates.chatDisconnectEventReceived) {
612
- handleChatDisconnect(props, state, setWebChatStyles);
613
- }
611
+ handleChatDisconnect(props, state, setWebChatStyles);
614
612
  }, [state.appStates.chatDisconnectEventReceived]);
615
613
  const initiateEndChatOnBrowserUnload = () => {
616
614
  var _DataStoreManager$cli;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.5.1-main.76c6a71",
3
+ "version": "1.5.1-main.c3533cf",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",