contentoh-components-library 21.3.18 → 21.3.20
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/assets/sounds/newMessage.mp3 +0 -0
- package/dist/components/atoms/GeneralInput/index.js +14 -1
- package/dist/components/molecules/SelectV2/test.js +0 -1
- package/dist/components/organisms/Chat/Chat.stories.js +1 -1
- package/dist/components/organisms/Chat/ContainerItems/index.js +1 -1
- package/dist/components/organisms/Chat/ContentChat/index.js +59 -22
- package/dist/components/organisms/Chat/Header/index.js +1 -2
- package/package.json +3 -2
- package/src/assets/sounds/newMessage.mp3 +0 -0
- package/src/components/atoms/GeneralInput/index.js +10 -0
- package/src/components/molecules/SelectV2/test.js +0 -1
- package/src/components/organisms/Chat/Chat.stories.js +1 -1
- package/src/components/organisms/Chat/ContainerItems/index.js +2 -2
- package/src/components/organisms/Chat/ContentChat/index.js +34 -12
- package/src/components/organisms/Chat/Header/index.js +0 -1
|
Binary file
|
|
@@ -114,6 +114,18 @@ var GeneralInput = function GeneralInput(_ref) {
|
|
|
114
114
|
|
|
115
115
|
setRequiredEmpty(isRequired && (((_textValue$value = textValue.value) === null || _textValue$value === void 0 ? void 0 : _textValue$value.length) === 0 || textValue.value === undefined));
|
|
116
116
|
}, [textValue]);
|
|
117
|
+
|
|
118
|
+
var numberInputOnWheelPreventChange = function numberInputOnWheelPreventChange(e) {
|
|
119
|
+
// Prevent the input value change
|
|
120
|
+
e.target.blur(); // Prevent the page/container scrolling
|
|
121
|
+
|
|
122
|
+
e.stopPropagation(); // Refocus immediately, on the next tick (after the current function is done)
|
|
123
|
+
|
|
124
|
+
setTimeout(function () {
|
|
125
|
+
return e.target.focus();
|
|
126
|
+
}, 0);
|
|
127
|
+
};
|
|
128
|
+
|
|
117
129
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
|
|
118
130
|
isRequired: requiredEmpty,
|
|
119
131
|
children: [(optionList === null || optionList === void 0 ? void 0 : optionList.length) > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("select", {
|
|
@@ -150,7 +162,8 @@ var GeneralInput = function GeneralInput(_ref) {
|
|
|
150
162
|
},
|
|
151
163
|
maxLength: maxChar,
|
|
152
164
|
required: isRequired,
|
|
153
|
-
onKeyDown: onKeyDown
|
|
165
|
+
onKeyDown: onKeyDown,
|
|
166
|
+
onWheel: numberInputOnWheelPreventChange
|
|
154
167
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputFormatter.InputFormatter, {
|
|
155
168
|
name: inputName,
|
|
156
169
|
inputId: inputId,
|
|
@@ -65,7 +65,6 @@ var TestSelectV2 = function TestSelectV2() {
|
|
|
65
65
|
multiple: false,
|
|
66
66
|
borderType: "oval",
|
|
67
67
|
onChange: function onChange(selectedItems) {
|
|
68
|
-
console.log("onChange:", selectedItems);
|
|
69
68
|
setSelected(selectedItems);
|
|
70
69
|
}
|
|
71
70
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
@@ -286,7 +286,7 @@ var ContainerItems = function ContainerItems(props) {
|
|
|
286
286
|
|
|
287
287
|
var getUserCreatedItem = function getUserCreatedItem(ownMessage, item, lastUserId) {
|
|
288
288
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Slide, {
|
|
289
|
-
id: "itemScroll",
|
|
289
|
+
id: "itemScroll-" + item.id,
|
|
290
290
|
direction: ownMessage ? "left" : "right",
|
|
291
291
|
in: true,
|
|
292
292
|
timeout: 500,
|
|
@@ -19,6 +19,8 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
19
19
|
|
|
20
20
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
21
21
|
|
|
22
|
+
var _reactHowler = _interopRequireDefault(require("react-howler"));
|
|
23
|
+
|
|
22
24
|
var _styles = require("./styles");
|
|
23
25
|
|
|
24
26
|
var _react = require("react");
|
|
@@ -43,6 +45,8 @@ var _handle_http = require("../../../../global-files/handle_http");
|
|
|
43
45
|
|
|
44
46
|
var _utils = require("../../../../global-files/utils");
|
|
45
47
|
|
|
48
|
+
var _newMessage = _interopRequireDefault(require("../../../../assets/sounds/newMessage.mp3"));
|
|
49
|
+
|
|
46
50
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
47
51
|
|
|
48
52
|
var ContentChat = function ContentChat(props) {
|
|
@@ -160,7 +164,12 @@ var ContentChat = function ContentChat(props) {
|
|
|
160
164
|
}),
|
|
161
165
|
_useState28 = (0, _slicedToArray2.default)(_useState27, 2),
|
|
162
166
|
errorUpdate = _useState28[0],
|
|
163
|
-
setErrorUpdate = _useState28[1];
|
|
167
|
+
setErrorUpdate = _useState28[1];
|
|
168
|
+
|
|
169
|
+
var _useState29 = (0, _react.useState)(false),
|
|
170
|
+
_useState30 = (0, _slicedToArray2.default)(_useState29, 2),
|
|
171
|
+
playSound = _useState30[0],
|
|
172
|
+
setPlaySound = _useState30[1]; // matar update al desmontar el componente del chat
|
|
164
173
|
|
|
165
174
|
|
|
166
175
|
(0, _react.useEffect)(function () {
|
|
@@ -192,7 +201,6 @@ var ContentChat = function ContentChat(props) {
|
|
|
192
201
|
//return; -- descomentarizar para hacer pruebas sin update
|
|
193
202
|
if (startUpdate == 0) return;
|
|
194
203
|
var processID = setTimeout(function () {
|
|
195
|
-
console.log("update chat execute");
|
|
196
204
|
setRunUpdate(function (prev) {
|
|
197
205
|
return prev + 1;
|
|
198
206
|
});
|
|
@@ -210,7 +218,7 @@ var ContentChat = function ContentChat(props) {
|
|
|
210
218
|
} else if (chatType === "order_product") {
|
|
211
219
|
if (companies) getUpdateLatestOrderProduct();else getInitialOrderProduct();
|
|
212
220
|
} else {
|
|
213
|
-
if (singleChat.items) getUpdateLatestTicket();else getInitialTicket();
|
|
221
|
+
if (singleChat.items) getUpdateLatestTicket(true);else getInitialTicket();
|
|
214
222
|
}
|
|
215
223
|
}, [runUpdate]);
|
|
216
224
|
/*=======================================================================
|
|
@@ -805,11 +813,17 @@ var ContentChat = function ContentChat(props) {
|
|
|
805
813
|
var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
|
806
814
|
var _dataChat$currentUser9, _dataChat$currentUser10, _dataChat$currentUser11, _dataChat$currentUser12;
|
|
807
815
|
|
|
808
|
-
var
|
|
816
|
+
var fromUpdate,
|
|
817
|
+
dataUser,
|
|
818
|
+
paramsQuery,
|
|
819
|
+
response,
|
|
820
|
+
newSingleChat,
|
|
821
|
+
_args9 = arguments;
|
|
809
822
|
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
810
823
|
while (1) {
|
|
811
824
|
switch (_context9.prev = _context9.next) {
|
|
812
825
|
case 0:
|
|
826
|
+
fromUpdate = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : false;
|
|
813
827
|
dataUser = {
|
|
814
828
|
id: (_dataChat$currentUser9 = dataChat.currentUser) === null || _dataChat$currentUser9 === void 0 ? void 0 : _dataChat$currentUser9.id,
|
|
815
829
|
companyId: (_dataChat$currentUser10 = dataChat.currentUser) === null || _dataChat$currentUser10 === void 0 ? void 0 : _dataChat$currentUser10.companyId,
|
|
@@ -822,12 +836,12 @@ var ContentChat = function ContentChat(props) {
|
|
|
822
836
|
currentUser: (0, _utils.encodeUriJson)(dataUser),
|
|
823
837
|
currentItemsFront: (0, _utils.encodeUriJson)(getItemsIdSingleChat())
|
|
824
838
|
};
|
|
825
|
-
_context9.next =
|
|
839
|
+
_context9.next = 5;
|
|
826
840
|
return (0, _handle_http.fetchGET)(process.env.REACT_APP_TICKETS_CHAT_ENDPOINT, paramsQuery, {
|
|
827
841
|
Authorization: (_dataChat$currentUser12 = dataChat.currentUser) === null || _dataChat$currentUser12 === void 0 ? void 0 : _dataChat$currentUser12.token
|
|
828
842
|
});
|
|
829
843
|
|
|
830
|
-
case
|
|
844
|
+
case 5:
|
|
831
845
|
response = _context9.sent;
|
|
832
846
|
//programar update en 20s
|
|
833
847
|
setStartUpdate(function (prev) {
|
|
@@ -835,7 +849,7 @@ var ContentChat = function ContentChat(props) {
|
|
|
835
849
|
});
|
|
836
850
|
|
|
837
851
|
if (response.body) {
|
|
838
|
-
_context9.next =
|
|
852
|
+
_context9.next = 11;
|
|
839
853
|
break;
|
|
840
854
|
}
|
|
841
855
|
|
|
@@ -859,7 +873,7 @@ var ContentChat = function ContentChat(props) {
|
|
|
859
873
|
});
|
|
860
874
|
return _context9.abrupt("return");
|
|
861
875
|
|
|
862
|
-
case
|
|
876
|
+
case 11:
|
|
863
877
|
// limpiar error update
|
|
864
878
|
if (errorUpdate.startDate) {
|
|
865
879
|
setErrorUpdate({});
|
|
@@ -870,12 +884,20 @@ var ContentChat = function ContentChat(props) {
|
|
|
870
884
|
|
|
871
885
|
updateAllUsers(response.body.users); // actualizar los items del chat
|
|
872
886
|
|
|
887
|
+
if (!(response.body.items.length === 0)) {
|
|
888
|
+
_context9.next = 16;
|
|
889
|
+
break;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
return _context9.abrupt("return");
|
|
893
|
+
|
|
894
|
+
case 16:
|
|
873
895
|
newSingleChat = (0, _objectSpread3.default)({}, singleChat);
|
|
874
|
-
newSingleChat.items = addNewItemsChat(newSingleChat.items, response.body.items);
|
|
896
|
+
newSingleChat.items = addNewItemsChat(newSingleChat.items, response.body.items, fromUpdate);
|
|
875
897
|
newSingleChat.statusChat = response.body.data.statusChat;
|
|
876
898
|
setSingleChat(newSingleChat);
|
|
877
899
|
|
|
878
|
-
case
|
|
900
|
+
case 20:
|
|
879
901
|
case "end":
|
|
880
902
|
return _context9.stop();
|
|
881
903
|
}
|
|
@@ -1268,19 +1290,31 @@ var ContentChat = function ContentChat(props) {
|
|
|
1268
1290
|
var addNewItemsChat = function addNewItemsChat() {
|
|
1269
1291
|
var currentItems = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1270
1292
|
var newItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
1271
|
-
var
|
|
1272
|
-
var itemsId =
|
|
1273
|
-
|
|
1293
|
+
var fromUpdate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1294
|
+
var itemsId = {};
|
|
1295
|
+
currentItems.forEach(function (item) {
|
|
1296
|
+
itemsId[item.id] = item;
|
|
1274
1297
|
});
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
if (!itemsId
|
|
1278
|
-
|
|
1279
|
-
|
|
1298
|
+
var thereAreNewItems = false;
|
|
1299
|
+
newItems.forEach(function (newitem) {
|
|
1300
|
+
if (!itemsId[newitem.id]) {
|
|
1301
|
+
itemsId[newitem.id] = newitem;
|
|
1302
|
+
thereAreNewItems = true;
|
|
1280
1303
|
}
|
|
1304
|
+
});
|
|
1305
|
+
|
|
1306
|
+
if (thereAreNewItems && fromUpdate) {
|
|
1307
|
+
setPlaySound(true);
|
|
1308
|
+
setTimeout(function () {
|
|
1309
|
+
setPlaySound(false);
|
|
1310
|
+
}, 5000);
|
|
1281
1311
|
}
|
|
1282
1312
|
|
|
1283
|
-
return
|
|
1313
|
+
return Object.values(itemsId).sort(function (a, b) {
|
|
1314
|
+
if (a.id < b.id) return 1;
|
|
1315
|
+
if (a.id > b.id) return -1;
|
|
1316
|
+
return 0;
|
|
1317
|
+
});
|
|
1284
1318
|
};
|
|
1285
1319
|
|
|
1286
1320
|
var updateAllUsers = function updateAllUsers() {
|
|
@@ -1410,8 +1444,8 @@ var ContentChat = function ContentChat(props) {
|
|
|
1410
1444
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loading.Loading, {});
|
|
1411
1445
|
};
|
|
1412
1446
|
|
|
1413
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
1414
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
|
|
1447
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
1448
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
|
|
1415
1449
|
children: [(chatContainerType !== "fixed" || !isSingleChat()) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Header.Header, {
|
|
1416
1450
|
showBtnClose: showBtnClose,
|
|
1417
1451
|
onClickBtnClose: onClickBtnClose,
|
|
@@ -1422,7 +1456,10 @@ var ContentChat = function ContentChat(props) {
|
|
|
1422
1456
|
setShowChatsList(true);
|
|
1423
1457
|
}
|
|
1424
1458
|
}), renderBodyChat()]
|
|
1425
|
-
})
|
|
1459
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHowler.default, {
|
|
1460
|
+
src: _newMessage.default,
|
|
1461
|
+
playing: playSound
|
|
1462
|
+
})]
|
|
1426
1463
|
});
|
|
1427
1464
|
};
|
|
1428
1465
|
|
|
@@ -25,8 +25,7 @@ var Header = function Header(props) {
|
|
|
25
25
|
chatCompany = props.chatCompany,
|
|
26
26
|
multipleCompanies = props.multipleCompanies,
|
|
27
27
|
onClickBtnChooseChat = props.onClickBtnChooseChat,
|
|
28
|
-
onClickBtnClose = props.onClickBtnClose;
|
|
29
|
-
|
|
28
|
+
onClickBtnClose = props.onClickBtnClose;
|
|
30
29
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
31
30
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
|
|
32
31
|
children: [showChatsList ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contentoh-components-library",
|
|
3
|
-
"version": "21.3.
|
|
3
|
+
"version": "21.3.20",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@aws-amplify/auth": "^4.5.3",
|
|
6
6
|
"@aws-amplify/datastore": "^3.11.0",
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
"@babel/runtime": "^7.17.2",
|
|
9
9
|
"@emotion/react": "^11.10.5",
|
|
10
10
|
"@emotion/styled": "^11.10.5",
|
|
11
|
-
"@mui/material": "^5.11.1",
|
|
12
11
|
"@fortawesome/fontawesome-svg-core": "^6.2.0",
|
|
13
12
|
"@fortawesome/free-regular-svg-icons": "^6.2.0",
|
|
14
13
|
"@fortawesome/free-solid-svg-icons": "^6.2.0",
|
|
15
14
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
15
|
+
"@mui/material": "^5.11.1",
|
|
16
16
|
"@mui/styled-engine-sc": "^5.10.6",
|
|
17
17
|
"@storybook/addon-postcss": "^2.0.0",
|
|
18
18
|
"@testing-library/jest-dom": "^5.11.4",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"react-dom": "^17.0.2",
|
|
36
36
|
"react-draft-wysiwyg": "^1.14.7",
|
|
37
37
|
"react-dropzone": "^12.0.4",
|
|
38
|
+
"react-howler": "^5.2.0",
|
|
38
39
|
"react-image-fallback": "^8.0.0",
|
|
39
40
|
"react-quill": "^1.3.5",
|
|
40
41
|
"react-router-dom": "^5.3.3",
|
|
Binary file
|
|
@@ -90,6 +90,15 @@ export const GeneralInput = ({
|
|
|
90
90
|
);
|
|
91
91
|
}, [textValue]);
|
|
92
92
|
|
|
93
|
+
const numberInputOnWheelPreventChange = (e) => {
|
|
94
|
+
// Prevent the input value change
|
|
95
|
+
e.target.blur();
|
|
96
|
+
// Prevent the page/container scrolling
|
|
97
|
+
e.stopPropagation();
|
|
98
|
+
// Refocus immediately, on the next tick (after the current function is done)
|
|
99
|
+
setTimeout(() => e.target.focus(), 0);
|
|
100
|
+
};
|
|
101
|
+
|
|
93
102
|
return (
|
|
94
103
|
<Container isRequired={requiredEmpty}>
|
|
95
104
|
{optionList?.length > 0 ? (
|
|
@@ -125,6 +134,7 @@ export const GeneralInput = ({
|
|
|
125
134
|
maxLength={maxChar}
|
|
126
135
|
required={isRequired}
|
|
127
136
|
onKeyDown={onKeyDown}
|
|
137
|
+
onWheel={numberInputOnWheelPreventChange}
|
|
128
138
|
/>
|
|
129
139
|
) : (
|
|
130
140
|
<InputFormatter
|
|
@@ -272,7 +272,7 @@ export const ContainerItems = (props) => {
|
|
|
272
272
|
const getUserCreatedItem = (ownMessage, item, lastUserId) => {
|
|
273
273
|
return (
|
|
274
274
|
<Slide
|
|
275
|
-
id={"itemScroll"}
|
|
275
|
+
id={"itemScroll-" + item.id}
|
|
276
276
|
direction={ownMessage ? "left" : "right"}
|
|
277
277
|
in={true}
|
|
278
278
|
timeout={500}
|
|
@@ -460,7 +460,7 @@ export const ContainerItems = (props) => {
|
|
|
460
460
|
|
|
461
461
|
return (
|
|
462
462
|
<>
|
|
463
|
-
<Container id=
|
|
463
|
+
<Container id="containerItems">
|
|
464
464
|
<div className="btn-loadMore">
|
|
465
465
|
{showBtnLoadMore && (
|
|
466
466
|
<ButtonV2
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import ReactHowler from 'react-howler'
|
|
1
2
|
import { Container } from "./styles";
|
|
2
3
|
import { useEffect, useState } from "react";
|
|
3
4
|
import { NotFound } from "../../../atoms/NotFound";
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
isStringEmpty,
|
|
15
16
|
isValidNaturalNumber,
|
|
16
17
|
} from "../../../../global-files/utils";
|
|
18
|
+
import newMessage from "../../../../assets/sounds/newMessage.mp3"
|
|
17
19
|
|
|
18
20
|
export const ContentChat = (props) => {
|
|
19
21
|
const {
|
|
@@ -64,6 +66,7 @@ export const ContentChat = (props) => {
|
|
|
64
66
|
startDate: undefined, // Date()
|
|
65
67
|
lastDate: undefined, // Date()
|
|
66
68
|
});
|
|
69
|
+
const [playSound, setPlaySound] = useState(false);
|
|
67
70
|
|
|
68
71
|
// matar update al desmontar el componente del chat
|
|
69
72
|
useEffect(() => {
|
|
@@ -96,7 +99,6 @@ export const ContentChat = (props) => {
|
|
|
96
99
|
//return; -- descomentarizar para hacer pruebas sin update
|
|
97
100
|
if (startUpdate == 0) return;
|
|
98
101
|
const processID = setTimeout(() => {
|
|
99
|
-
console.log("update chat execute");
|
|
100
102
|
setRunUpdate((prev) => prev + 1);
|
|
101
103
|
}, 5000);
|
|
102
104
|
setProcessUpdateID(processID);
|
|
@@ -113,7 +115,7 @@ export const ContentChat = (props) => {
|
|
|
113
115
|
if (companies) getUpdateLatestOrderProduct();
|
|
114
116
|
else getInitialOrderProduct();
|
|
115
117
|
} else {
|
|
116
|
-
if (singleChat.items) getUpdateLatestTicket();
|
|
118
|
+
if (singleChat.items) getUpdateLatestTicket(true);
|
|
117
119
|
else getInitialTicket();
|
|
118
120
|
}
|
|
119
121
|
}, [runUpdate]);
|
|
@@ -486,7 +488,7 @@ export const ContentChat = (props) => {
|
|
|
486
488
|
}
|
|
487
489
|
};
|
|
488
490
|
|
|
489
|
-
const getUpdateLatestTicket = async () => {
|
|
491
|
+
const getUpdateLatestTicket = async (fromUpdate = false) => {
|
|
490
492
|
const dataUser = {
|
|
491
493
|
id: dataChat.currentUser?.id,
|
|
492
494
|
companyId: dataChat.currentUser?.companyId,
|
|
@@ -532,12 +534,15 @@ export const ContentChat = (props) => {
|
|
|
532
534
|
// actualizar la lista de los users
|
|
533
535
|
updateAllUsers(response.body.users);
|
|
534
536
|
// actualizar los items del chat
|
|
537
|
+
if (response.body.items.length === 0) return;
|
|
535
538
|
let newSingleChat = { ...singleChat };
|
|
536
539
|
newSingleChat.items = addNewItemsChat(
|
|
537
540
|
newSingleChat.items,
|
|
538
|
-
response.body.items
|
|
541
|
+
response.body.items,
|
|
542
|
+
fromUpdate,
|
|
539
543
|
);
|
|
540
544
|
newSingleChat.statusChat = response.body.data.statusChat;
|
|
545
|
+
|
|
541
546
|
setSingleChat(newSingleChat);
|
|
542
547
|
};
|
|
543
548
|
|
|
@@ -710,16 +715,29 @@ export const ContentChat = (props) => {
|
|
|
710
715
|
return items;
|
|
711
716
|
};
|
|
712
717
|
|
|
713
|
-
const addNewItemsChat = (currentItems = [], newItems = []) => {
|
|
714
|
-
let
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
718
|
+
const addNewItemsChat = (currentItems = [], newItems = [], fromUpdate = false) => {
|
|
719
|
+
let itemsId = {};
|
|
720
|
+
currentItems.forEach((item) => {
|
|
721
|
+
itemsId[item.id] = item;
|
|
722
|
+
});
|
|
723
|
+
let thereAreNewItems = false;
|
|
724
|
+
newItems.forEach((newitem) => {
|
|
725
|
+
if (!itemsId[newitem.id]) {
|
|
726
|
+
itemsId[newitem.id] = newitem;
|
|
727
|
+
thereAreNewItems = true;
|
|
720
728
|
}
|
|
729
|
+
});
|
|
730
|
+
if (thereAreNewItems && fromUpdate) {
|
|
731
|
+
setPlaySound(true);
|
|
732
|
+
setTimeout(() => {
|
|
733
|
+
setPlaySound(false);
|
|
734
|
+
}, 5000);
|
|
721
735
|
}
|
|
722
|
-
return
|
|
736
|
+
return Object.values(itemsId).sort((a, b) => {
|
|
737
|
+
if (a.id < b.id) return 1;
|
|
738
|
+
if (a.id > b.id) return -1;
|
|
739
|
+
return 0;
|
|
740
|
+
});
|
|
723
741
|
};
|
|
724
742
|
|
|
725
743
|
const updateAllUsers = (newUsers = {}) => {
|
|
@@ -892,6 +910,10 @@ export const ContentChat = (props) => {
|
|
|
892
910
|
{/* body */}
|
|
893
911
|
{renderBodyChat()}
|
|
894
912
|
</Container>
|
|
913
|
+
<ReactHowler
|
|
914
|
+
src={newMessage}
|
|
915
|
+
playing={playSound}
|
|
916
|
+
/>
|
|
895
917
|
</>
|
|
896
918
|
);
|
|
897
919
|
};
|