@esvndev/es-react-template-chat 0.0.91 → 0.0.92
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/index.js +77 -135
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -135
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -72397,141 +72397,83 @@ const ChatLog = (props) => {
|
|
|
72397
72397
|
return (jsx("div", { className: "group-image-item image-container", children: jsx("img", { style: { maxWidth: "100%", maxHeight: 360 }, src: `${CDN_URL_VIEW}/${it.path.trim()}`, onClick: () => handlePreview(it), alt: "" }) }, index));
|
|
72398
72398
|
}) })), jsx("div", { className: "", style: { fontSize: "12px", color: "#476285" }, children: moment(chat.time).format("HH:mm") })] }) }) }));
|
|
72399
72399
|
}, [expandedMessages, handlePreview, mentionItems]);
|
|
72400
|
-
|
|
72401
|
-
|
|
72402
|
-
|
|
72403
|
-
|
|
72404
|
-
|
|
72405
|
-
|
|
72406
|
-
|
|
72407
|
-
|
|
72408
|
-
|
|
72409
|
-
|
|
72410
|
-
|
|
72411
|
-
|
|
72412
|
-
|
|
72413
|
-
|
|
72414
|
-
|
|
72415
|
-
|
|
72416
|
-
|
|
72417
|
-
|
|
72418
|
-
|
|
72419
|
-
|
|
72420
|
-
|
|
72421
|
-
|
|
72422
|
-
|
|
72423
|
-
|
|
72424
|
-
|
|
72425
|
-
|
|
72426
|
-
|
|
72427
|
-
|
|
72428
|
-
|
|
72429
|
-
|
|
72430
|
-
|
|
72431
|
-
|
|
72432
|
-
|
|
72433
|
-
|
|
72434
|
-
|
|
72435
|
-
|
|
72436
|
-
|
|
72437
|
-
|
|
72438
|
-
|
|
72439
|
-
|
|
72440
|
-
|
|
72441
|
-
|
|
72442
|
-
|
|
72443
|
-
|
|
72444
|
-
|
|
72445
|
-
|
|
72446
|
-
|
|
72447
|
-
|
|
72448
|
-
|
|
72449
|
-
|
|
72450
|
-
|
|
72451
|
-
|
|
72452
|
-
|
|
72453
|
-
|
|
72454
|
-
|
|
72455
|
-
|
|
72456
|
-
|
|
72457
|
-
|
|
72458
|
-
|
|
72459
|
-
|
|
72460
|
-
|
|
72461
|
-
|
|
72462
|
-
|
|
72463
|
-
|
|
72464
|
-
|
|
72465
|
-
|
|
72466
|
-
|
|
72467
|
-
|
|
72468
|
-
|
|
72469
|
-
|
|
72470
|
-
|
|
72471
|
-
|
|
72472
|
-
|
|
72473
|
-
|
|
72474
|
-
|
|
72475
|
-
|
|
72476
|
-
|
|
72477
|
-
// <>
|
|
72478
|
-
// <div>
|
|
72479
|
-
// <span style={{ fontWeight: "bold", marginRight: "5px" }}>
|
|
72480
|
-
// {msg?.name}
|
|
72481
|
-
// </span>
|
|
72482
|
-
// <span>được <span style={{ fontWeight: "bold", marginRight: "5px" }}>{chat?.createdBy?.name}</span> xoá khỏi nhóm</span>
|
|
72483
|
-
// </div>
|
|
72484
|
-
// </>
|
|
72485
|
-
// )
|
|
72486
|
-
// }, [dataProfile])
|
|
72487
|
-
// const renderChatNotification = useCallback((chat: any) => {
|
|
72488
|
-
// const parseChatMsg = (msg: string) => {
|
|
72489
|
-
// if (!msg) { return [] }
|
|
72490
|
-
// try {
|
|
72491
|
-
// const parsed = typeof msg === 'string' ? JSON.parse(msg) : msg
|
|
72492
|
-
// return Array.isArray(parsed) ? parsed : [parsed]
|
|
72493
|
-
// } catch (err) {
|
|
72494
|
-
// console.error('JSON parse error:', err)
|
|
72495
|
-
// return []
|
|
72496
|
-
// }
|
|
72497
|
-
// }
|
|
72498
|
-
// const dataParse = parseChatMsg(chat.msg)
|
|
72499
|
-
// // ✅ FIX: Kiểm tra array trước khi dùng slice
|
|
72500
|
-
// if (!Array.isArray(dataParse) || dataParse.length === 0) {
|
|
72501
|
-
// return (
|
|
72502
|
-
// <div>
|
|
72503
|
-
// <span>Đã có thay đổi trong nhóm</span>
|
|
72504
|
-
// </div>
|
|
72505
|
-
// )
|
|
72506
|
-
// }
|
|
72507
|
-
// const displayedItems = dataParse.slice(0, 2)
|
|
72508
|
-
// const extraCount = Math.max(0, dataParse.length - displayedItems.length)
|
|
72509
|
-
// return (
|
|
72510
|
-
// <>
|
|
72511
|
-
// <div>
|
|
72512
|
-
// {displayedItems.map((item: any, index: any) => (
|
|
72513
|
-
// <strong key={index}>
|
|
72514
|
-
// {item.name}
|
|
72515
|
-
// {index < displayedItems.length - 1 && ", "}
|
|
72516
|
-
// </strong>
|
|
72517
|
-
// ))}
|
|
72518
|
-
// {dataParse.length > 3 && (
|
|
72519
|
-
// <strong>
|
|
72520
|
-
// <span style={{ fontWeight: "normal" }}>{" và "}</span>{" "}
|
|
72521
|
-
// {extraCount} người khác
|
|
72522
|
-
// </strong>
|
|
72523
|
-
// )}
|
|
72524
|
-
// {" được "}
|
|
72525
|
-
// {chat?.createdBy?.id === dataProfile?.id ? (
|
|
72526
|
-
// <span>bạn </span>
|
|
72527
|
-
// ) : (
|
|
72528
|
-
// <strong style={{ marginRight: "5px" }}>{chat?.createdByName}</strong>
|
|
72529
|
-
// )}
|
|
72530
|
-
// thêm vào nhóm
|
|
72531
|
-
// </div>
|
|
72532
|
-
// </>
|
|
72533
|
-
// )
|
|
72534
|
-
// }, [dataProfile])
|
|
72400
|
+
const getLinkPreviewData = (urlString) => {
|
|
72401
|
+
try {
|
|
72402
|
+
const hasProtocol = /^https?:\/\//i.test(urlString);
|
|
72403
|
+
const href = hasProtocol ? urlString : `https://${urlString}`;
|
|
72404
|
+
const url = new URL(href);
|
|
72405
|
+
const displayUrl = urlString.length > 80 ? `${urlString.slice(0, 77)}...` : urlString;
|
|
72406
|
+
return {
|
|
72407
|
+
href,
|
|
72408
|
+
displayUrl,
|
|
72409
|
+
host: url.host
|
|
72410
|
+
};
|
|
72411
|
+
}
|
|
72412
|
+
catch (e) {
|
|
72413
|
+
return {
|
|
72414
|
+
href: urlString,
|
|
72415
|
+
displayUrl: urlString,
|
|
72416
|
+
host: ''
|
|
72417
|
+
};
|
|
72418
|
+
}
|
|
72419
|
+
};
|
|
72420
|
+
const renderLinkPreview = (urlString) => {
|
|
72421
|
+
const { href, displayUrl, host } = getLinkPreviewData(urlString);
|
|
72422
|
+
return (jsx(Fragment$1, { children: jsx("a", { href: href, target: "_blank", rel: "noreferrer", style: {
|
|
72423
|
+
textDecoration: 'none',
|
|
72424
|
+
color: 'inherit'
|
|
72425
|
+
}, children: jsxs("div", { style: {
|
|
72426
|
+
marginTop: 4,
|
|
72427
|
+
marginBottom: 4,
|
|
72428
|
+
padding: '8px 10px',
|
|
72429
|
+
borderRadius: 8,
|
|
72430
|
+
backgroundColor: '#eef5ff',
|
|
72431
|
+
border: '1px solid #d3e2ff',
|
|
72432
|
+
maxWidth: 420
|
|
72433
|
+
}, children: [jsx("div", { style: {
|
|
72434
|
+
fontSize: 14,
|
|
72435
|
+
fontWeight: 500,
|
|
72436
|
+
color: '#1d4f91',
|
|
72437
|
+
wordBreak: 'break-word'
|
|
72438
|
+
}, children: displayUrl }), host && (jsx("div", { style: {
|
|
72439
|
+
marginTop: 4,
|
|
72440
|
+
fontSize: 12,
|
|
72441
|
+
color: '#6f6b7d'
|
|
72442
|
+
}, children: host }))] }) }) }));
|
|
72443
|
+
};
|
|
72444
|
+
useCallback((chat) => {
|
|
72445
|
+
const msg = JSON.parse(chat?.msg);
|
|
72446
|
+
if (chat?.createdById === dataProfile?.id) {
|
|
72447
|
+
return (jsx(Fragment$1, { children: jsxs("div", { children: [jsx("span", { style: { fontWeight: "bold", marginRight: "5px" }, children: msg?.name }), jsx("span", { children: "\u0111\u01B0\u1EE3c b\u1EA1n xo\u00E1 kh\u1ECFi nh\u00F3m" })] }) }));
|
|
72448
|
+
}
|
|
72449
|
+
if (chat?.createdById === msg?.id) {
|
|
72450
|
+
return (jsx(Fragment$1, { children: jsxs("div", { children: [jsx("span", { style: { fontWeight: "bold", marginRight: "5px" }, children: msg?.name }), jsx("span", { children: "\u0111\u00E3 r\u1EDDi kh\u1ECFi nh\u00F3m" })] }) }));
|
|
72451
|
+
}
|
|
72452
|
+
return (jsx(Fragment$1, { children: jsxs("div", { children: [jsx("span", { style: { fontWeight: "bold", marginRight: "5px" }, children: msg?.name }), jsxs("span", { children: ["\u0111\u01B0\u1EE3c ", jsx("span", { style: { fontWeight: "bold", marginRight: "5px" }, children: chat?.createdBy?.name }), " xo\u00E1 kh\u1ECFi nh\u00F3m"] })] }) }));
|
|
72453
|
+
}, [dataProfile]);
|
|
72454
|
+
useCallback((chat) => {
|
|
72455
|
+
const parseChatMsg = (msg) => {
|
|
72456
|
+
if (!msg) {
|
|
72457
|
+
return [];
|
|
72458
|
+
}
|
|
72459
|
+
try {
|
|
72460
|
+
const parsed = typeof msg === 'string' ? JSON.parse(msg) : msg;
|
|
72461
|
+
return Array.isArray(parsed) ? parsed : [parsed];
|
|
72462
|
+
}
|
|
72463
|
+
catch (err) {
|
|
72464
|
+
console.error('JSON parse error:', err);
|
|
72465
|
+
return [];
|
|
72466
|
+
}
|
|
72467
|
+
};
|
|
72468
|
+
const dataParse = parseChatMsg(chat.msg);
|
|
72469
|
+
// ✅ FIX: Kiểm tra array trước khi dùng slice
|
|
72470
|
+
if (!Array.isArray(dataParse) || dataParse.length === 0) {
|
|
72471
|
+
return (jsx("div", { children: jsx("span", { children: "\u0110\u00E3 c\u00F3 thay \u0111\u1ED5i trong nh\u00F3m" }) }));
|
|
72472
|
+
}
|
|
72473
|
+
const displayedItems = dataParse.slice(0, 2);
|
|
72474
|
+
const extraCount = Math.max(0, dataParse.length - displayedItems.length);
|
|
72475
|
+
return (jsx(Fragment$1, { children: jsxs("div", { children: [displayedItems.map((item, index) => (jsxs("strong", { children: [item.name, index < displayedItems.length - 1 && ", "] }, index))), dataParse.length > 3 && (jsxs("strong", { children: [jsx("span", { style: { fontWeight: "normal" }, children: " và " }), " ", extraCount, " ng\u01B0\u1EDDi kh\u00E1c"] })), " được ", chat?.createdBy?.id === dataProfile?.id ? (jsx("span", { children: "b\u1EA1n " })) : (jsx("strong", { style: { marginRight: "5px" }, children: chat?.createdByName })), "th\u00EAm v\u00E0o nh\u00F3m"] }) }));
|
|
72476
|
+
}, [dataProfile]);
|
|
72535
72477
|
// const renderChatImage = useCallback((chat: any) => {
|
|
72536
72478
|
// const files = chat.path
|
|
72537
72479
|
// if (!files || !Array.isArray(files) || files.length === 0) {
|