@defra/flood-webchat 0.0.1-beta.40 → 0.0.1-beta.42
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/dist/client.js +179 -29
- package/dist/client.js.map +1 -1
- package/package.json +2 -1
- package/src/client/components/availability/availability.jsx +17 -9
- package/src/client/components/chat/chat.jsx +36 -2
- package/src/client/components/live-region.jsx +55 -0
- package/src/client/components/panel/panel.jsx +18 -2
- package/src/client/components/screens/feedback.jsx +2 -2
- package/src/client/components/screens/request-chat.jsx +7 -1
- package/src/client/scss/_settings.scss +21 -0
- package/src/client/store/AppProvider.jsx +10 -2
- package/src/client/store/actions-map.js +13 -4
package/dist/client.js
CHANGED
|
@@ -19,6 +19,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
19
19
|
/* harmony import */ var _skip_link_jsx__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../skip-link.jsx */ "./src/client/components/skip-link.jsx");
|
|
20
20
|
/* harmony import */ var _store_useApp__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../store/useApp */ "./src/client/store/useApp.js");
|
|
21
21
|
/* harmony import */ var _lib_history_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../lib/history.js */ "./src/client/lib/history.js");
|
|
22
|
+
/* harmony import */ var _live_region_jsx__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../live-region.jsx */ "./src/client/components/live-region.jsx");
|
|
23
|
+
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
|
|
@@ -33,9 +35,11 @@ function Availability() {
|
|
|
33
35
|
unseenCount,
|
|
34
36
|
threadId,
|
|
35
37
|
setUnseenCount,
|
|
36
|
-
setInstigatorId
|
|
38
|
+
setInstigatorId,
|
|
39
|
+
setLiveRegionText
|
|
37
40
|
} = (0,_store_useApp__WEBPACK_IMPORTED_MODULE_4__.useApp)();
|
|
38
41
|
const buttonRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)();
|
|
42
|
+
const showUnseenCount = unseenCount > 0 && !isChatOpen;
|
|
39
43
|
const onClick = e => {
|
|
40
44
|
e.preventDefault();
|
|
41
45
|
setUnseenCount(0);
|
|
@@ -58,6 +62,14 @@ function Availability() {
|
|
|
58
62
|
setChatVisibility(!isChatOpen);
|
|
59
63
|
}
|
|
60
64
|
};
|
|
65
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
66
|
+
if (showUnseenCount) {
|
|
67
|
+
setLiveRegionText(`Floodline Webchat - ${unseenCount} new messages`);
|
|
68
|
+
}
|
|
69
|
+
return () => {
|
|
70
|
+
setLiveRegionText();
|
|
71
|
+
};
|
|
72
|
+
}, [unseenCount, isChatOpen]);
|
|
61
73
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
62
74
|
const onScroll = () => {
|
|
63
75
|
if (!threadId) {
|
|
@@ -79,10 +91,6 @@ function Availability() {
|
|
|
79
91
|
document.removeEventListener('scroll', onScroll);
|
|
80
92
|
};
|
|
81
93
|
}, [threadId, isChatOpen, availability]);
|
|
82
|
-
let TextComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, "Show chat");
|
|
83
|
-
if (!threadId) {
|
|
84
|
-
TextComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, "Start chat");
|
|
85
|
-
}
|
|
86
94
|
switch (availability) {
|
|
87
95
|
case 'AVAILABLE':
|
|
88
96
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
@@ -100,9 +108,9 @@ function Availability() {
|
|
|
100
108
|
onKeyDown: onKeyDown,
|
|
101
109
|
role: "button",
|
|
102
110
|
"data-module": "govuk-button"
|
|
103
|
-
},
|
|
111
|
+
}, !threadId ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, "Start chat") : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, "Show chat"), showUnseenCount ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
|
|
104
112
|
className: "wc-availability__unseen"
|
|
105
|
-
}, unseenCount) : null))), isChatOpen && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_panel_panel_jsx__WEBPACK_IMPORTED_MODULE_2__.Panel, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_skip_link_jsx__WEBPACK_IMPORTED_MODULE_3__.SkipLink, null));
|
|
113
|
+
}, unseenCount) : null))), isChatOpen && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_panel_panel_jsx__WEBPACK_IMPORTED_MODULE_2__.Panel, null), showUnseenCount ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_live_region_jsx__WEBPACK_IMPORTED_MODULE_6__.LiveRegion, null) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_skip_link_jsx__WEBPACK_IMPORTED_MODULE_3__.SkipLink, null));
|
|
106
114
|
case 'EXISTING':
|
|
107
115
|
case 'UNAVAILABLE':
|
|
108
116
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", {
|
|
@@ -155,8 +163,10 @@ function Chat({
|
|
|
155
163
|
agent,
|
|
156
164
|
agentStatus,
|
|
157
165
|
isAgentTyping,
|
|
166
|
+
isChatOpen,
|
|
158
167
|
settings,
|
|
159
|
-
isKeyboard
|
|
168
|
+
isKeyboard,
|
|
169
|
+
setLiveRegionText
|
|
160
170
|
} = (0,_store_useApp_js__WEBPACK_IMPORTED_MODULE_4__.useApp)();
|
|
161
171
|
const [userMessage, setUserMessage] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)('');
|
|
162
172
|
const [focusVisibleWithin, setFocusVisibleWithin] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
|
|
@@ -181,12 +191,39 @@ function Chat({
|
|
|
181
191
|
};
|
|
182
192
|
const agentName = agent?.nickname || agent?.firstName;
|
|
183
193
|
const connectionHeadlineText = (0,_lib_agent_status_headline_js__WEBPACK_IMPORTED_MODULE_7__.agentStatusHeadline)(availability, agentStatus, agentName);
|
|
194
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
195
|
+
if (connectionHeadlineText) {
|
|
196
|
+
setLiveRegionText(`Floodline Webchat - ${connectionHeadlineText}`);
|
|
197
|
+
}
|
|
198
|
+
return () => {
|
|
199
|
+
setLiveRegionText();
|
|
200
|
+
};
|
|
201
|
+
}, [connectionHeadlineText]);
|
|
202
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
203
|
+
if (isAgentTyping && isChatOpen) {
|
|
204
|
+
setLiveRegionText(`${agentName} is typing...`);
|
|
205
|
+
}
|
|
206
|
+
return () => {
|
|
207
|
+
setLiveRegionText();
|
|
208
|
+
};
|
|
209
|
+
}, [isAgentTyping, isChatOpen]);
|
|
210
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
211
|
+
const lastAgentMessage = messages[messages.length - 1];
|
|
212
|
+
if (agentStatus !== 'closed' && lastAgentMessage?.direction === 'outbound') {
|
|
213
|
+
setLiveRegionText(`${agentName} said: ${lastAgentMessage.text}`);
|
|
214
|
+
}
|
|
215
|
+
return () => {
|
|
216
|
+
setLiveRegionText();
|
|
217
|
+
};
|
|
218
|
+
}, [messages]);
|
|
184
219
|
const sendMessage = () => {
|
|
185
220
|
if (messageRef.current.value.length === 0 || agentStatus === 'closed') {
|
|
186
221
|
return;
|
|
187
222
|
}
|
|
188
223
|
try {
|
|
189
|
-
|
|
224
|
+
const message = messageRef.current.value.trim();
|
|
225
|
+
thread.sendTextMessage(message);
|
|
226
|
+
setLiveRegionText(`You said: ${message}`);
|
|
190
227
|
} catch (err) {
|
|
191
228
|
console.log('[Chat Error] sendMessage', err);
|
|
192
229
|
}
|
|
@@ -382,6 +419,72 @@ const ErrorSummary = ({
|
|
|
382
419
|
|
|
383
420
|
/***/ }),
|
|
384
421
|
|
|
422
|
+
/***/ "./src/client/components/live-region.jsx":
|
|
423
|
+
/*!***********************************************!*\
|
|
424
|
+
!*** ./src/client/components/live-region.jsx ***!
|
|
425
|
+
\***********************************************/
|
|
426
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
427
|
+
|
|
428
|
+
__webpack_require__.r(__webpack_exports__);
|
|
429
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
430
|
+
/* harmony export */ LiveRegion: () => (/* binding */ LiveRegion)
|
|
431
|
+
/* harmony export */ });
|
|
432
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
433
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
434
|
+
/* harmony import */ var lodash_debounce__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash.debounce */ "lodash.debounce");
|
|
435
|
+
/* harmony import */ var lodash_debounce__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_debounce__WEBPACK_IMPORTED_MODULE_1__);
|
|
436
|
+
/* harmony import */ var _store_useApp__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../store/useApp */ "./src/client/store/useApp.js");
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
const DEBOUNCE_MILLISECONDS = 2000;
|
|
441
|
+
const LiveRegion = () => {
|
|
442
|
+
const {
|
|
443
|
+
agentStatus,
|
|
444
|
+
liveRegionText,
|
|
445
|
+
setLiveRegionText
|
|
446
|
+
} = (0,_store_useApp__WEBPACK_IMPORTED_MODULE_2__.useApp)();
|
|
447
|
+
const [textA, setTextA] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)();
|
|
448
|
+
const [textB, setTextB] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)();
|
|
449
|
+
const isSessionEnded = agentStatus === 'closed' || agentStatus === null;
|
|
450
|
+
const clearText = () => {
|
|
451
|
+
setTextA();
|
|
452
|
+
setTextB();
|
|
453
|
+
};
|
|
454
|
+
const setText = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(lodash_debounce__WEBPACK_IMPORTED_MODULE_1___default()(text => {
|
|
455
|
+
if (textA) {
|
|
456
|
+
setTextB(text);
|
|
457
|
+
} else {
|
|
458
|
+
setTextA(text);
|
|
459
|
+
}
|
|
460
|
+
}, DEBOUNCE_MILLISECONDS), [textA, textB]);
|
|
461
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
462
|
+
if (liveRegionText) {
|
|
463
|
+
clearText();
|
|
464
|
+
setText(liveRegionText);
|
|
465
|
+
}
|
|
466
|
+
if (isSessionEnded) {
|
|
467
|
+
clearText();
|
|
468
|
+
setLiveRegionText();
|
|
469
|
+
}
|
|
470
|
+
return () => {
|
|
471
|
+
clearText();
|
|
472
|
+
setLiveRegionText();
|
|
473
|
+
};
|
|
474
|
+
}, [liveRegionText]);
|
|
475
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
476
|
+
className: "wc-live",
|
|
477
|
+
"aria-live": "polite",
|
|
478
|
+
"aria-atomic": "true"
|
|
479
|
+
}, textA), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
480
|
+
className: "wc-live",
|
|
481
|
+
"aria-live": "polite",
|
|
482
|
+
"aria-atomic": "true"
|
|
483
|
+
}, textB));
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
/***/ }),
|
|
487
|
+
|
|
385
488
|
/***/ "./src/client/components/message/message.jsx":
|
|
386
489
|
/*!***************************************************!*\
|
|
387
490
|
!*** ./src/client/components/message/message.jsx ***!
|
|
@@ -562,10 +665,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
562
665
|
/* harmony import */ var _screens_end_chat_jsx__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../screens/end-chat.jsx */ "./src/client/components/screens/end-chat.jsx");
|
|
563
666
|
/* harmony import */ var _screens_settings_jsx__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../screens/settings.jsx */ "./src/client/components/screens/settings.jsx");
|
|
564
667
|
/* harmony import */ var _screens_feedback_jsx__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../screens/feedback.jsx */ "./src/client/components/screens/feedback.jsx");
|
|
565
|
-
/* harmony import */ var
|
|
566
|
-
/* harmony import */ var
|
|
567
|
-
/* harmony import */ var
|
|
568
|
-
/* harmony import */ var
|
|
668
|
+
/* harmony import */ var _live_region_jsx__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../live-region.jsx */ "./src/client/components/live-region.jsx");
|
|
669
|
+
/* harmony import */ var _store_useApp_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../store/useApp.js */ "./src/client/store/useApp.js");
|
|
670
|
+
/* harmony import */ var _store_useChatSdk_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../store/useChatSdk.js */ "./src/client/store/useChatSdk.js");
|
|
671
|
+
/* harmony import */ var _hooks_useFocusedElements_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../hooks/useFocusedElements.js */ "./src/client/hooks/useFocusedElements.js");
|
|
672
|
+
/* harmony import */ var _lib_history_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../lib/history.js */ "./src/client/lib/history.js");
|
|
673
|
+
|
|
569
674
|
|
|
570
675
|
|
|
571
676
|
|
|
@@ -594,13 +699,13 @@ function Panel() {
|
|
|
594
699
|
setUnseenCount,
|
|
595
700
|
isMobile,
|
|
596
701
|
isKeyboard
|
|
597
|
-
} = (0,
|
|
702
|
+
} = (0,_store_useApp_js__WEBPACK_IMPORTED_MODULE_11__.useApp)();
|
|
598
703
|
const {
|
|
599
704
|
fetchThread,
|
|
600
705
|
fetchMessages
|
|
601
|
-
} = (0,
|
|
706
|
+
} = (0,_store_useChatSdk_js__WEBPACK_IMPORTED_MODULE_12__.useChatSdk)(sdk);
|
|
602
707
|
const [screen, setScreen] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(threadId ? 2 : 0);
|
|
603
|
-
(0,
|
|
708
|
+
(0,_hooks_useFocusedElements_js__WEBPACK_IMPORTED_MODULE_13__.useFocusedElements)(screen);
|
|
604
709
|
const onEscapeKey = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(e => {
|
|
605
710
|
if (e.key === 'Escape' || e.key === 'Esc') {
|
|
606
711
|
if (threadId) {
|
|
@@ -608,11 +713,19 @@ function Panel() {
|
|
|
608
713
|
setUnseenCount(0);
|
|
609
714
|
}
|
|
610
715
|
setChatVisibility(false);
|
|
611
|
-
(0,
|
|
612
|
-
document.getElementById(instigatorId)?.focus();
|
|
716
|
+
(0,_lib_history_js__WEBPACK_IMPORTED_MODULE_14__.historyReplaceState)();
|
|
613
717
|
}
|
|
614
718
|
}, [thread, threadId, setUnseenCount, setChatVisibility]);
|
|
615
719
|
|
|
720
|
+
/**
|
|
721
|
+
* Focus previously focused element when closing the webchat
|
|
722
|
+
*/
|
|
723
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
724
|
+
return () => {
|
|
725
|
+
document.getElementById(instigatorId)?.focus();
|
|
726
|
+
};
|
|
727
|
+
}, []);
|
|
728
|
+
|
|
616
729
|
/**
|
|
617
730
|
* We need ammend classes on the body element to handle mobile behaviour
|
|
618
731
|
*/
|
|
@@ -699,7 +812,10 @@ function Panel() {
|
|
|
699
812
|
break;
|
|
700
813
|
case 4:
|
|
701
814
|
ScreenComponent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_screens_feedback_jsx__WEBPACK_IMPORTED_MODULE_9__.Feedback, {
|
|
702
|
-
onCancel: () =>
|
|
815
|
+
onCancel: () => {
|
|
816
|
+
setChatVisibility(false);
|
|
817
|
+
(0,_lib_history_js__WEBPACK_IMPORTED_MODULE_14__.historyReplaceState)();
|
|
818
|
+
}
|
|
703
819
|
});
|
|
704
820
|
break;
|
|
705
821
|
case 5:
|
|
@@ -724,7 +840,7 @@ function Panel() {
|
|
|
724
840
|
"aria-labelledby": "wc-header-title"
|
|
725
841
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
726
842
|
className: "wc-panel__inner"
|
|
727
|
-
}, ScreenComponent));
|
|
843
|
+
}, ScreenComponent), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_live_region_jsx__WEBPACK_IMPORTED_MODULE_10__.LiveRegion, null));
|
|
728
844
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/(0,react_dom__WEBPACK_IMPORTED_MODULE_1__.createPortal)(Component, document.body));
|
|
729
845
|
}
|
|
730
846
|
|
|
@@ -843,7 +959,6 @@ function Feedback({
|
|
|
843
959
|
const tmpThreadId = window.localStorage.getItem('tmpThreadId');
|
|
844
960
|
window.location.href = `https://defragroup.eu.qualtrics.com/jfe/form/SV_8dgFSJcxxIfqx5Y?Id=${tmpThreadId}&Source=${window.location.href}`;
|
|
845
961
|
window.localStorage.removeItem('tmpThreadId');
|
|
846
|
-
onCancel(e);
|
|
847
962
|
};
|
|
848
963
|
const feedbackClose = async e => {
|
|
849
964
|
window.localStorage.removeItem('tmpThreadId');
|
|
@@ -874,7 +989,7 @@ function Feedback({
|
|
|
874
989
|
rel: "noreferrer",
|
|
875
990
|
onKeyDown: handleKeyPress,
|
|
876
991
|
onClick: feedbackSend
|
|
877
|
-
}, "
|
|
992
|
+
}, "Give Feedback")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("p", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
|
|
878
993
|
id: "feedback-close",
|
|
879
994
|
className: "wc-link govuk-link",
|
|
880
995
|
href: "#",
|
|
@@ -979,7 +1094,8 @@ function RequestChat({
|
|
|
979
1094
|
sdk,
|
|
980
1095
|
setCustomerId,
|
|
981
1096
|
setThreadId,
|
|
982
|
-
setThread
|
|
1097
|
+
setThread,
|
|
1098
|
+
setLiveRegionText
|
|
983
1099
|
} = (0,_store_useApp_js__WEBPACK_IMPORTED_MODULE_4__.useApp)();
|
|
984
1100
|
const {
|
|
985
1101
|
fetchCustomerId,
|
|
@@ -1006,6 +1122,11 @@ function RequestChat({
|
|
|
1006
1122
|
setQuestionLength(e.target.value.length);
|
|
1007
1123
|
};
|
|
1008
1124
|
const buttonLabel = isButtonDisabled ? 'Requesting...' : 'Request Chat';
|
|
1125
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
1126
|
+
if (isButtonDisabled) {
|
|
1127
|
+
setLiveRegionText(buttonLabel);
|
|
1128
|
+
}
|
|
1129
|
+
}, [isButtonDisabled]);
|
|
1009
1130
|
const onRequestChat = async e => {
|
|
1010
1131
|
e.preventDefault();
|
|
1011
1132
|
if (isButtonDisabled) {
|
|
@@ -1650,6 +1771,9 @@ const AppProvider = ({
|
|
|
1650
1771
|
type: 'SET_AGENT_TYPING',
|
|
1651
1772
|
payload: false
|
|
1652
1773
|
});
|
|
1774
|
+
dispatch({
|
|
1775
|
+
type: 'SET_LIVE_REGION_TEXT'
|
|
1776
|
+
});
|
|
1653
1777
|
};
|
|
1654
1778
|
const onMessageCreated = e => {
|
|
1655
1779
|
dispatch({
|
|
@@ -1732,13 +1856,14 @@ const AppProvider = ({
|
|
|
1732
1856
|
if (window.location.hash === '#webchat') {
|
|
1733
1857
|
setChatVisibility(true);
|
|
1734
1858
|
}
|
|
1735
|
-
const onBrowserNavigation =
|
|
1859
|
+
const onBrowserNavigation = () => {
|
|
1736
1860
|
if (window.location.hash === '#webchat') {
|
|
1737
1861
|
setChatVisibility(true);
|
|
1738
1862
|
} else {
|
|
1739
1863
|
setChatVisibility(false);
|
|
1740
1864
|
}
|
|
1741
|
-
}
|
|
1865
|
+
};
|
|
1866
|
+
window.addEventListener('popstate', onBrowserNavigation);
|
|
1742
1867
|
return () => {
|
|
1743
1868
|
window.removeEventListener('popstate', onBrowserNavigation);
|
|
1744
1869
|
};
|
|
@@ -1795,6 +1920,12 @@ const AppProvider = ({
|
|
|
1795
1920
|
payload: id
|
|
1796
1921
|
});
|
|
1797
1922
|
};
|
|
1923
|
+
const setLiveRegionText = text => {
|
|
1924
|
+
dispatch({
|
|
1925
|
+
type: 'SET_LIVE_REGION_TEXT',
|
|
1926
|
+
payload: text
|
|
1927
|
+
});
|
|
1928
|
+
};
|
|
1798
1929
|
|
|
1799
1930
|
/**
|
|
1800
1931
|
* Application-wide state and state functions
|
|
@@ -1810,6 +1941,7 @@ const AppProvider = ({
|
|
|
1810
1941
|
setUnseenCount,
|
|
1811
1942
|
setChatVisibility,
|
|
1812
1943
|
setInstigatorId,
|
|
1944
|
+
setLiveRegionText,
|
|
1813
1945
|
onLiveChatRecovered,
|
|
1814
1946
|
onAssignedAgentChanged,
|
|
1815
1947
|
onAgentTypingStarted,
|
|
@@ -1889,16 +2021,17 @@ const setThread = (state, payload) => {
|
|
|
1889
2021
|
thread: payload
|
|
1890
2022
|
};
|
|
1891
2023
|
};
|
|
1892
|
-
const
|
|
2024
|
+
const setMessages = (state, payload) => {
|
|
1893
2025
|
return {
|
|
1894
2026
|
...state,
|
|
1895
|
-
messages:
|
|
2027
|
+
messages: (0,_lib_transform_messages__WEBPACK_IMPORTED_MODULE_0__.transformMessages)(payload).reverse()
|
|
1896
2028
|
};
|
|
1897
2029
|
};
|
|
1898
|
-
const
|
|
2030
|
+
const setMessage = (state, payload) => {
|
|
1899
2031
|
return {
|
|
1900
2032
|
...state,
|
|
1901
|
-
|
|
2033
|
+
message: (0,_lib_transform_messages__WEBPACK_IMPORTED_MODULE_0__.transformMessage)(payload),
|
|
2034
|
+
messages: [...state.messages, (0,_lib_transform_messages__WEBPACK_IMPORTED_MODULE_0__.transformMessage)(payload)]
|
|
1902
2035
|
};
|
|
1903
2036
|
};
|
|
1904
2037
|
const setAgent = (state, payload) => {
|
|
@@ -1931,6 +2064,12 @@ const setInstigatorId = (state, payload) => {
|
|
|
1931
2064
|
instigatorId: payload
|
|
1932
2065
|
};
|
|
1933
2066
|
};
|
|
2067
|
+
const setLiveRegionText = (state, payload) => {
|
|
2068
|
+
return {
|
|
2069
|
+
...state,
|
|
2070
|
+
liveRegionText: payload
|
|
2071
|
+
};
|
|
2072
|
+
};
|
|
1934
2073
|
const toggleIsMobile = (state, payload) => {
|
|
1935
2074
|
return {
|
|
1936
2075
|
...state,
|
|
@@ -1957,6 +2096,7 @@ const actionsMap = {
|
|
|
1957
2096
|
SET_AGENT_STATUS: setAgentStatus,
|
|
1958
2097
|
SET_UNSEEN_COUNT: setUnseenCount,
|
|
1959
2098
|
SET_INSTIGATOR_ID: setInstigatorId,
|
|
2099
|
+
SET_LIVE_REGION_TEXT: setLiveRegionText,
|
|
1960
2100
|
TOGGLE_IS_MOBILE: toggleIsMobile,
|
|
1961
2101
|
TOGGLE_IS_KEYBOARD: toggleIsKeyboard
|
|
1962
2102
|
};
|
|
@@ -2103,6 +2243,16 @@ module.exports = require("@nice-devone/nice-cxone-chat-web-sdk");
|
|
|
2103
2243
|
|
|
2104
2244
|
/***/ }),
|
|
2105
2245
|
|
|
2246
|
+
/***/ "lodash.debounce":
|
|
2247
|
+
/*!**********************************!*\
|
|
2248
|
+
!*** external "lodash.debounce" ***!
|
|
2249
|
+
\**********************************/
|
|
2250
|
+
/***/ ((module) => {
|
|
2251
|
+
|
|
2252
|
+
module.exports = require("lodash.debounce");
|
|
2253
|
+
|
|
2254
|
+
/***/ }),
|
|
2255
|
+
|
|
2106
2256
|
/***/ "luxon":
|
|
2107
2257
|
/*!************************!*\
|
|
2108
2258
|
!*** external "luxon" ***!
|