@microsoft/omnichannel-chat-widget 1.6.2 → 1.6.3-main.18ee949
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.
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +28 -34
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/createReducer.js +653 -345
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +28 -34
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/createReducer.js +650 -343
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/lib/types/contexts/createReducer.d.ts +1 -0
- package/package.json +1 -1
|
@@ -57,6 +57,7 @@ var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDK
|
|
|
57
57
|
var _defaultAdaptiveCardStyles = require("../../webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles");
|
|
58
58
|
var _StartChatErrorPaneStateful = _interopRequireDefault(require("../../startchaterrorpanestateful/StartChatErrorPaneStateful"));
|
|
59
59
|
var _StartChatFailureType = require("../../../contexts/common/StartChatFailureType");
|
|
60
|
+
var _createReducer = require("../../../contexts/createReducer");
|
|
60
61
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
61
62
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
62
63
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -125,8 +126,12 @@ const LiveChatWidgetStateful = props => {
|
|
|
125
126
|
const isReconnectTriggered = async () => {
|
|
126
127
|
if ((0, _reconnectChatHelper.isReconnectEnabled)(props.chatConfig) === true && !(0, _reconnectChatHelper.isPersistentEnabled)(props.chatConfig)) {
|
|
127
128
|
const noValidReconnectId = await (0, _reconnectChatHelper.handleChatReconnect)(chatSDK, props, dispatch, setAdapter, _startChat.initStartChat, state);
|
|
129
|
+
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
130
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
131
|
+
payload: null
|
|
132
|
+
});
|
|
128
133
|
// If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
|
|
129
|
-
if (!noValidReconnectId && (
|
|
134
|
+
if (!noValidReconnectId && (inMemoryState.appStates.conversationState === _ConversationState.ConversationState.Active || inMemoryState.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat)) {
|
|
130
135
|
return true;
|
|
131
136
|
}
|
|
132
137
|
}
|
|
@@ -340,7 +345,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
340
345
|
|
|
341
346
|
// Start chat from SDK Event
|
|
342
347
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(msg => {
|
|
343
|
-
var _msg$payload4, _msg$payload5, _msg$payload6;
|
|
348
|
+
var _msg$payload4, _msg$payload5, _msg$payload6, _inMemoryState$appSta, _inMemoryState$appSta2, _inMemoryState$appSta3, _inMemoryState$appSta4;
|
|
344
349
|
// If the startChat event is not initiated by the same tab. Ignore the call
|
|
345
350
|
if (!(0, _utils.isNullOrUndefined)(msg === null || msg === void 0 ? void 0 : (_msg$payload4 = msg.payload) === null || _msg$payload4 === void 0 ? void 0 : _msg$payload4.runtimeId) && (msg === null || msg === void 0 ? void 0 : (_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.runtimeId) !== _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
346
351
|
return;
|
|
@@ -368,12 +373,13 @@ const LiveChatWidgetStateful = props => {
|
|
|
368
373
|
Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
|
|
369
374
|
Description: "Start chat event received."
|
|
370
375
|
});
|
|
376
|
+
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
377
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
378
|
+
payload: null
|
|
379
|
+
});
|
|
371
380
|
|
|
372
|
-
//
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
// Chat not found in cache - scenario: explicitly clearing cache and calling startChat SDK method
|
|
376
|
-
if (persistedState === undefined) {
|
|
381
|
+
// Only initiate new chat if widget runtime state is one of the followings
|
|
382
|
+
if (((_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.conversationState) === _ConversationState.ConversationState.Closed || ((_inMemoryState$appSta2 = inMemoryState.appStates) === null || _inMemoryState$appSta2 === void 0 ? void 0 : _inMemoryState$appSta2.conversationState) === _ConversationState.ConversationState.InActive || ((_inMemoryState$appSta3 = inMemoryState.appStates) === null || _inMemoryState$appSta3 === void 0 ? void 0 : _inMemoryState$appSta3.conversationState) === _ConversationState.ConversationState.Postchat) {
|
|
377
383
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
378
384
|
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
379
385
|
});
|
|
@@ -381,33 +387,21 @@ const LiveChatWidgetStateful = props => {
|
|
|
381
387
|
return;
|
|
382
388
|
}
|
|
383
389
|
|
|
384
|
-
//
|
|
385
|
-
if (
|
|
386
|
-
var
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
dispatch({
|
|
400
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
401
|
-
payload: false
|
|
402
|
-
});
|
|
403
|
-
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
404
|
-
eventName: _TelemetryConstants.BroadcastEvent.MaximizeChat,
|
|
405
|
-
payload: {
|
|
406
|
-
height: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : (_persistedState$domai2 = _persistedState$domai.widgetSize) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.height,
|
|
407
|
-
width: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai3 = persistedState.domainStates) === null || _persistedState$domai3 === void 0 ? void 0 : (_persistedState$domai4 = _persistedState$domai3.widgetSize) === null || _persistedState$domai4 === void 0 ? void 0 : _persistedState$domai4.width
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
}
|
|
390
|
+
// If minimized, maximize the chat
|
|
391
|
+
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta4 = inMemoryState.appStates) === null || _inMemoryState$appSta4 === void 0 ? void 0 : _inMemoryState$appSta4.isMinimized) === true) {
|
|
392
|
+
var _inMemoryState$domain, _inMemoryState$domain2, _inMemoryState$domain3, _inMemoryState$domain4;
|
|
393
|
+
dispatch({
|
|
394
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
395
|
+
payload: false
|
|
396
|
+
});
|
|
397
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
398
|
+
eventName: _TelemetryConstants.BroadcastEvent.MaximizeChat,
|
|
399
|
+
payload: {
|
|
400
|
+
height: inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain = inMemoryState.domainStates) === null || _inMemoryState$domain === void 0 ? void 0 : (_inMemoryState$domain2 = _inMemoryState$domain.widgetSize) === null || _inMemoryState$domain2 === void 0 ? void 0 : _inMemoryState$domain2.height,
|
|
401
|
+
width: inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain3 = inMemoryState.domainStates) === null || _inMemoryState$domain3 === void 0 ? void 0 : (_inMemoryState$domain4 = _inMemoryState$domain3.widgetSize) === null || _inMemoryState$domain4 === void 0 ? void 0 : _inMemoryState$domain4.width
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
return;
|
|
411
405
|
}
|
|
412
406
|
});
|
|
413
407
|
|
|
@@ -52,4 +52,5 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
|
|
|
52
52
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SURVEY_MODE"] = 42] = "SET_SURVEY_MODE";
|
|
53
53
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONFIRMATION_STATE"] = 43] = "SET_CONFIRMATION_STATE";
|
|
54
54
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_PARTICIPANT_TYPE"] = 44] = "SET_POST_CHAT_PARTICIPANT_TYPE";
|
|
55
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["GET_IN_MEMORY_STATE"] = 45] = "GET_IN_MEMORY_STATE";
|
|
55
56
|
})(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));
|