@microsoft/omnichannel-chat-widget 1.8.1 → 1.8.2-main.4b1a5f0

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.
@@ -39,7 +39,7 @@ const ChatButtonStateful = props => {
39
39
  } = props;
40
40
  //Setting OutOfOperatingHours Flag
41
41
  //Setting OutOfOperatingHours Flag - to string conversion to normalize the value (could be boolean from other states or string directly from config)
42
- const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.useState)(state.appStates.outsideOperatingHours);
42
+ const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.useState)(false);
43
43
  const ref = (0, _react.useRef)(() => {
44
44
  return;
45
45
  });
@@ -100,7 +100,6 @@ const ChatButtonStateful = props => {
100
100
  ...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
101
101
  };
102
102
  (0, _react.useEffect)(() => {
103
- setOutOfOperatingHours(state.appStates.outsideOperatingHours);
104
103
  _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
105
104
  Event: _TelemetryConstants.TelemetryEvent.LCWChatButtonShow,
106
105
  ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers.LcwLoadToChatButtonTimer.milliSecondsElapsed
@@ -119,6 +118,13 @@ const ChatButtonStateful = props => {
119
118
  ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
120
119
  });
121
120
  }, []);
121
+ (0, _react.useEffect)(() => {
122
+ if (state.appStates.conversationState === _ConversationState.ConversationState.Closed) {
123
+ // If the conversation state is closed, check if we are outside operating hours
124
+ const isOutsideOperatingHours = state.appStates.outsideOperatingHours;
125
+ setOutOfOperatingHours(isOutsideOperatingHours);
126
+ }
127
+ }, [state.appStates.conversationState]);
122
128
  return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.ChatButton, {
123
129
  componentOverrides: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.componentOverrides,
124
130
  controlProps: outOfOperatingHours ? outOfOfficeControlProps : controlProps,
@@ -37,7 +37,7 @@ const HeaderStateful = props => {
37
37
  endChat
38
38
  } = props;
39
39
  //Setting OutOfOperatingHours Flag
40
- const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.useState)(state.appStates.outsideOperatingHours);
40
+ const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.useState)(false);
41
41
  const outOfOfficeStyleProps = Object.assign({}, _defaultOutOfOfficeHeaderStyleProps.defaultOutOfOfficeHeaderStyleProps, outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.styleProps);
42
42
 
43
43
  // For some reason state object is not getting updated values in this component
@@ -120,9 +120,6 @@ const HeaderStateful = props => {
120
120
  ...(outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.controlProps),
121
121
  hideCloseButton: state.appStates.conversationState === _ConversationState.ConversationState.OutOfOffice || (outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : (_outOfOfficeHeaderPro = outOfOfficeHeaderProps.controlProps) === null || _outOfOfficeHeaderPro === void 0 ? void 0 : _outOfOfficeHeaderPro.hideCloseButton)
122
122
  };
123
- (0, _react.useEffect)(() => {
124
- setOutOfOperatingHours(state.appStates.outsideOperatingHours);
125
- }, []);
126
123
  (0, _react.useEffect)(() => {
127
124
  var _state$domainStates2;
128
125
  localConfirmationPaneState.current = state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.confirmationState;
@@ -138,6 +135,13 @@ const HeaderStateful = props => {
138
135
  ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
139
136
  });
140
137
  }, []);
138
+ (0, _react.useEffect)(() => {
139
+ if (state.appStates.conversationState === _ConversationState.ConversationState.Closed) {
140
+ // If the conversation state is closed, check if we are outside operating hours
141
+ const isOutsideOperatingHours = state.appStates.outsideOperatingHours;
142
+ setOutOfOperatingHours(isOutsideOperatingHours);
143
+ }
144
+ }, [state.appStates.conversationState]);
141
145
  if (props.draggable === true) {
142
146
  var _generalStyleProps;
143
147
  const styleProps = outOfOperatingHours || state.appStates.conversationState === _ConversationState.ConversationState.OutOfOffice ? outOfOfficeStyleProps : headerProps === null || headerProps === void 0 ? void 0 : headerProps.styleProps;
@@ -284,7 +284,8 @@ const LiveChatWidgetStateful = props => {
284
284
  var _state$appStates6;
285
285
  if ((state === null || state === void 0 ? void 0 : (_state$appStates6 = state.appStates) === null || _state$appStates6 === void 0 ? void 0 : _state$appStates6.hideStartChatButton) === true) {
286
286
  //handle OOH pane
287
- if (state.appStates.outsideOperatingHours === true) {
287
+ // Only set OutOfOffice state for new conversations, allow existing Active/InActive conversations to continue
288
+ if (state.appStates.outsideOperatingHours === true && state.appStates.conversationState !== _ConversationState.ConversationState.Active) {
288
289
  dispatch({
289
290
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
290
291
  payload: _ConversationState.ConversationState.OutOfOffice
@@ -30,7 +30,7 @@ const getLiveChatWidgetContextInitialState = props => {
30
30
  * as part of the flow, the pre-chat will be detected and then it will be displayed properly
31
31
  * this case is only and only for pre-chat pane.
32
32
  * **/
33
- if (initialStateFromCache.appStates.conversationState === _ConversationState.ConversationState.Prechat || initialStateFromCache.appStates.conversationState === _ConversationState.ConversationState.OutOfOffice || outsideOperatingHours) {
33
+ if (initialStateFromCache.appStates.conversationState === _ConversationState.ConversationState.Prechat || initialStateFromCache.appStates.conversationState === _ConversationState.ConversationState.OutOfOffice || outsideOperatingHours && initialStateFromCache.appStates.conversationState !== _ConversationState.ConversationState.Active) {
34
34
  initialStateFromCache.appStates.conversationState = _ConversationState.ConversationState.Closed;
35
35
  // if we are resetting the conversation state, there is no point to obtain minimized state from cache
36
36
  initialStateFromCache.appStates.isMinimized = undefined;
@@ -30,7 +30,7 @@ export const ChatButtonStateful = props => {
30
30
  } = props;
31
31
  //Setting OutOfOperatingHours Flag
32
32
  //Setting OutOfOperatingHours Flag - to string conversion to normalize the value (could be boolean from other states or string directly from config)
33
- const [outOfOperatingHours, setOutOfOperatingHours] = useState(state.appStates.outsideOperatingHours);
33
+ const [outOfOperatingHours, setOutOfOperatingHours] = useState(false);
34
34
  const ref = useRef(() => {
35
35
  return;
36
36
  });
@@ -91,7 +91,6 @@ export const ChatButtonStateful = props => {
91
91
  ...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
92
92
  };
93
93
  useEffect(() => {
94
- setOutOfOperatingHours(state.appStates.outsideOperatingHours);
95
94
  TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
96
95
  Event: TelemetryEvent.LCWChatButtonShow,
97
96
  ElapsedTimeInMilliseconds: TelemetryTimers.LcwLoadToChatButtonTimer.milliSecondsElapsed
@@ -110,6 +109,13 @@ export const ChatButtonStateful = props => {
110
109
  ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
111
110
  });
112
111
  }, []);
112
+ useEffect(() => {
113
+ if (state.appStates.conversationState === ConversationState.Closed) {
114
+ // If the conversation state is closed, check if we are outside operating hours
115
+ const isOutsideOperatingHours = state.appStates.outsideOperatingHours;
116
+ setOutOfOperatingHours(isOutsideOperatingHours);
117
+ }
118
+ }, [state.appStates.conversationState]);
113
119
  return /*#__PURE__*/React.createElement(ChatButton, {
114
120
  componentOverrides: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.componentOverrides,
115
121
  controlProps: outOfOperatingHours ? outOfOfficeControlProps : controlProps,
@@ -28,7 +28,7 @@ export const HeaderStateful = props => {
28
28
  endChat
29
29
  } = props;
30
30
  //Setting OutOfOperatingHours Flag
31
- const [outOfOperatingHours, setOutOfOperatingHours] = useState(state.appStates.outsideOperatingHours);
31
+ const [outOfOperatingHours, setOutOfOperatingHours] = useState(false);
32
32
  const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeHeaderStyleProps, outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.styleProps);
33
33
 
34
34
  // For some reason state object is not getting updated values in this component
@@ -111,9 +111,6 @@ export const HeaderStateful = props => {
111
111
  ...(outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.controlProps),
112
112
  hideCloseButton: state.appStates.conversationState === ConversationState.OutOfOffice || (outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : (_outOfOfficeHeaderPro = outOfOfficeHeaderProps.controlProps) === null || _outOfOfficeHeaderPro === void 0 ? void 0 : _outOfOfficeHeaderPro.hideCloseButton)
113
113
  };
114
- useEffect(() => {
115
- setOutOfOperatingHours(state.appStates.outsideOperatingHours);
116
- }, []);
117
114
  useEffect(() => {
118
115
  var _state$domainStates2;
119
116
  localConfirmationPaneState.current = state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.confirmationState;
@@ -129,6 +126,13 @@ export const HeaderStateful = props => {
129
126
  ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
130
127
  });
131
128
  }, []);
129
+ useEffect(() => {
130
+ if (state.appStates.conversationState === ConversationState.Closed) {
131
+ // If the conversation state is closed, check if we are outside operating hours
132
+ const isOutsideOperatingHours = state.appStates.outsideOperatingHours;
133
+ setOutOfOperatingHours(isOutsideOperatingHours);
134
+ }
135
+ }, [state.appStates.conversationState]);
132
136
  if (props.draggable === true) {
133
137
  var _generalStyleProps;
134
138
  const styleProps = outOfOperatingHours || state.appStates.conversationState === ConversationState.OutOfOffice ? outOfOfficeStyleProps : headerProps === null || headerProps === void 0 ? void 0 : headerProps.styleProps;
@@ -276,7 +276,8 @@ export const LiveChatWidgetStateful = props => {
276
276
  var _state$appStates6;
277
277
  if ((state === null || state === void 0 ? void 0 : (_state$appStates6 = state.appStates) === null || _state$appStates6 === void 0 ? void 0 : _state$appStates6.hideStartChatButton) === true) {
278
278
  //handle OOH pane
279
- if (state.appStates.outsideOperatingHours === true) {
279
+ // Only set OutOfOffice state for new conversations, allow existing Active/InActive conversations to continue
280
+ if (state.appStates.outsideOperatingHours === true && state.appStates.conversationState !== ConversationState.Active) {
280
281
  dispatch({
281
282
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
282
283
  payload: ConversationState.OutOfOffice
@@ -24,7 +24,7 @@ export const getLiveChatWidgetContextInitialState = props => {
24
24
  * as part of the flow, the pre-chat will be detected and then it will be displayed properly
25
25
  * this case is only and only for pre-chat pane.
26
26
  * **/
27
- if (initialStateFromCache.appStates.conversationState === ConversationState.Prechat || initialStateFromCache.appStates.conversationState === ConversationState.OutOfOffice || outsideOperatingHours) {
27
+ if (initialStateFromCache.appStates.conversationState === ConversationState.Prechat || initialStateFromCache.appStates.conversationState === ConversationState.OutOfOffice || outsideOperatingHours && initialStateFromCache.appStates.conversationState !== ConversationState.Active) {
28
28
  initialStateFromCache.appStates.conversationState = ConversationState.Closed;
29
29
  // if we are resetting the conversation state, there is no point to obtain minimized state from cache
30
30
  initialStateFromCache.appStates.isMinimized = undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.8.1",
3
+ "version": "1.8.2-main.4b1a5f0",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",