@defra/flood-webchat 0.0.1-beta.40 → 0.0.1-beta.41
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 +178 -27
- 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 +1 -0
- 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
|
|
|
@@ -979,7 +1095,8 @@ function RequestChat({
|
|
|
979
1095
|
sdk,
|
|
980
1096
|
setCustomerId,
|
|
981
1097
|
setThreadId,
|
|
982
|
-
setThread
|
|
1098
|
+
setThread,
|
|
1099
|
+
setLiveRegionText
|
|
983
1100
|
} = (0,_store_useApp_js__WEBPACK_IMPORTED_MODULE_4__.useApp)();
|
|
984
1101
|
const {
|
|
985
1102
|
fetchCustomerId,
|
|
@@ -1006,6 +1123,11 @@ function RequestChat({
|
|
|
1006
1123
|
setQuestionLength(e.target.value.length);
|
|
1007
1124
|
};
|
|
1008
1125
|
const buttonLabel = isButtonDisabled ? 'Requesting...' : 'Request Chat';
|
|
1126
|
+
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
1127
|
+
if (isButtonDisabled) {
|
|
1128
|
+
setLiveRegionText(buttonLabel);
|
|
1129
|
+
}
|
|
1130
|
+
}, [isButtonDisabled]);
|
|
1009
1131
|
const onRequestChat = async e => {
|
|
1010
1132
|
e.preventDefault();
|
|
1011
1133
|
if (isButtonDisabled) {
|
|
@@ -1650,6 +1772,9 @@ const AppProvider = ({
|
|
|
1650
1772
|
type: 'SET_AGENT_TYPING',
|
|
1651
1773
|
payload: false
|
|
1652
1774
|
});
|
|
1775
|
+
dispatch({
|
|
1776
|
+
type: 'SET_LIVE_REGION_TEXT'
|
|
1777
|
+
});
|
|
1653
1778
|
};
|
|
1654
1779
|
const onMessageCreated = e => {
|
|
1655
1780
|
dispatch({
|
|
@@ -1732,13 +1857,14 @@ const AppProvider = ({
|
|
|
1732
1857
|
if (window.location.hash === '#webchat') {
|
|
1733
1858
|
setChatVisibility(true);
|
|
1734
1859
|
}
|
|
1735
|
-
const onBrowserNavigation =
|
|
1860
|
+
const onBrowserNavigation = () => {
|
|
1736
1861
|
if (window.location.hash === '#webchat') {
|
|
1737
1862
|
setChatVisibility(true);
|
|
1738
1863
|
} else {
|
|
1739
1864
|
setChatVisibility(false);
|
|
1740
1865
|
}
|
|
1741
|
-
}
|
|
1866
|
+
};
|
|
1867
|
+
window.addEventListener('popstate', onBrowserNavigation);
|
|
1742
1868
|
return () => {
|
|
1743
1869
|
window.removeEventListener('popstate', onBrowserNavigation);
|
|
1744
1870
|
};
|
|
@@ -1795,6 +1921,12 @@ const AppProvider = ({
|
|
|
1795
1921
|
payload: id
|
|
1796
1922
|
});
|
|
1797
1923
|
};
|
|
1924
|
+
const setLiveRegionText = text => {
|
|
1925
|
+
dispatch({
|
|
1926
|
+
type: 'SET_LIVE_REGION_TEXT',
|
|
1927
|
+
payload: text
|
|
1928
|
+
});
|
|
1929
|
+
};
|
|
1798
1930
|
|
|
1799
1931
|
/**
|
|
1800
1932
|
* Application-wide state and state functions
|
|
@@ -1810,6 +1942,7 @@ const AppProvider = ({
|
|
|
1810
1942
|
setUnseenCount,
|
|
1811
1943
|
setChatVisibility,
|
|
1812
1944
|
setInstigatorId,
|
|
1945
|
+
setLiveRegionText,
|
|
1813
1946
|
onLiveChatRecovered,
|
|
1814
1947
|
onAssignedAgentChanged,
|
|
1815
1948
|
onAgentTypingStarted,
|
|
@@ -1889,16 +2022,17 @@ const setThread = (state, payload) => {
|
|
|
1889
2022
|
thread: payload
|
|
1890
2023
|
};
|
|
1891
2024
|
};
|
|
1892
|
-
const
|
|
2025
|
+
const setMessages = (state, payload) => {
|
|
1893
2026
|
return {
|
|
1894
2027
|
...state,
|
|
1895
|
-
messages:
|
|
2028
|
+
messages: (0,_lib_transform_messages__WEBPACK_IMPORTED_MODULE_0__.transformMessages)(payload).reverse()
|
|
1896
2029
|
};
|
|
1897
2030
|
};
|
|
1898
|
-
const
|
|
2031
|
+
const setMessage = (state, payload) => {
|
|
1899
2032
|
return {
|
|
1900
2033
|
...state,
|
|
1901
|
-
|
|
2034
|
+
message: (0,_lib_transform_messages__WEBPACK_IMPORTED_MODULE_0__.transformMessage)(payload),
|
|
2035
|
+
messages: [...state.messages, (0,_lib_transform_messages__WEBPACK_IMPORTED_MODULE_0__.transformMessage)(payload)]
|
|
1902
2036
|
};
|
|
1903
2037
|
};
|
|
1904
2038
|
const setAgent = (state, payload) => {
|
|
@@ -1931,6 +2065,12 @@ const setInstigatorId = (state, payload) => {
|
|
|
1931
2065
|
instigatorId: payload
|
|
1932
2066
|
};
|
|
1933
2067
|
};
|
|
2068
|
+
const setLiveRegionText = (state, payload) => {
|
|
2069
|
+
return {
|
|
2070
|
+
...state,
|
|
2071
|
+
liveRegionText: payload
|
|
2072
|
+
};
|
|
2073
|
+
};
|
|
1934
2074
|
const toggleIsMobile = (state, payload) => {
|
|
1935
2075
|
return {
|
|
1936
2076
|
...state,
|
|
@@ -1957,6 +2097,7 @@ const actionsMap = {
|
|
|
1957
2097
|
SET_AGENT_STATUS: setAgentStatus,
|
|
1958
2098
|
SET_UNSEEN_COUNT: setUnseenCount,
|
|
1959
2099
|
SET_INSTIGATOR_ID: setInstigatorId,
|
|
2100
|
+
SET_LIVE_REGION_TEXT: setLiveRegionText,
|
|
1960
2101
|
TOGGLE_IS_MOBILE: toggleIsMobile,
|
|
1961
2102
|
TOGGLE_IS_KEYBOARD: toggleIsKeyboard
|
|
1962
2103
|
};
|
|
@@ -2103,6 +2244,16 @@ module.exports = require("@nice-devone/nice-cxone-chat-web-sdk");
|
|
|
2103
2244
|
|
|
2104
2245
|
/***/ }),
|
|
2105
2246
|
|
|
2247
|
+
/***/ "lodash.debounce":
|
|
2248
|
+
/*!**********************************!*\
|
|
2249
|
+
!*** external "lodash.debounce" ***!
|
|
2250
|
+
\**********************************/
|
|
2251
|
+
/***/ ((module) => {
|
|
2252
|
+
|
|
2253
|
+
module.exports = require("lodash.debounce");
|
|
2254
|
+
|
|
2255
|
+
/***/ }),
|
|
2256
|
+
|
|
2106
2257
|
/***/ "luxon":
|
|
2107
2258
|
/*!************************!*\
|
|
2108
2259
|
!*** external "luxon" ***!
|