@droppii-org/chat-sdk 0.0.33 → 0.0.35

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.
Files changed (87) hide show
  1. package/dist/components/conversation/ConversationBySessionItem.d.ts.map +1 -1
  2. package/dist/components/conversation/ConversationBySessionItem.js +7 -70
  3. package/dist/components/conversation/DeskConversationList.d.ts.map +1 -1
  4. package/dist/components/conversation/DeskConversationList.js +44 -22
  5. package/dist/components/mediaCollection/FileCollection.d.ts.map +1 -1
  6. package/dist/components/mediaCollection/FileCollection.js +7 -6
  7. package/dist/components/mediaCollection/ImageCollection.d.ts.map +1 -1
  8. package/dist/components/mediaCollection/ImageCollection.js +7 -6
  9. package/dist/components/mediaCollection/VideoCollection.d.ts.map +1 -1
  10. package/dist/components/mediaCollection/VideoCollection.js +7 -6
  11. package/dist/components/mediaCollection/index.js +5 -5
  12. package/dist/components/message/MessageList.d.ts +1 -0
  13. package/dist/components/message/MessageList.d.ts.map +1 -1
  14. package/dist/components/message/MessageList.js +67 -15
  15. package/dist/components/message/footer/index.d.ts +1 -5
  16. package/dist/components/message/footer/index.d.ts.map +1 -1
  17. package/dist/components/message/footer/index.js +5 -4
  18. package/dist/components/message/item/index.d.ts +4 -3
  19. package/dist/components/message/item/index.d.ts.map +1 -1
  20. package/dist/components/message/item/index.js +24 -32
  21. package/dist/components/searchConversation/SearchAll.d.ts +6 -1
  22. package/dist/components/searchConversation/SearchAll.d.ts.map +1 -1
  23. package/dist/components/searchConversation/SearchAll.js +28 -4
  24. package/dist/components/searchConversation/SearchConversationAsMessages.d.ts +4 -1
  25. package/dist/components/searchConversation/SearchConversationAsMessages.d.ts.map +1 -1
  26. package/dist/components/searchConversation/SearchConversationAsMessages.js +18 -3
  27. package/dist/components/searchConversation/SearchConversationAsUsers.d.ts +4 -1
  28. package/dist/components/searchConversation/SearchConversationAsUsers.d.ts.map +1 -1
  29. package/dist/components/searchConversation/SearchConversationAsUsers.js +14 -3
  30. package/dist/components/searchConversation/index.d.ts +4 -1
  31. package/dist/components/searchConversation/index.d.ts.map +1 -1
  32. package/dist/components/searchConversation/index.js +8 -7
  33. package/dist/components/searchConversation/item/SearchItemAsMessage.d.ts +8 -0
  34. package/dist/components/searchConversation/item/SearchItemAsMessage.d.ts.map +1 -0
  35. package/dist/components/searchConversation/item/SearchItemAsMessage.js +51 -0
  36. package/dist/components/searchConversation/item/SearchItemAsUser.d.ts +8 -0
  37. package/dist/components/searchConversation/item/SearchItemAsUser.d.ts.map +1 -0
  38. package/dist/components/searchConversation/item/SearchItemAsUser.js +13 -0
  39. package/dist/components/session/DeskAssignedSession.d.ts.map +1 -1
  40. package/dist/components/session/DeskAssignedSession.js +11 -13
  41. package/dist/constants/index.d.ts +3 -0
  42. package/dist/constants/index.d.ts.map +1 -1
  43. package/dist/constants/index.js +3 -0
  44. package/dist/context/ChatContext.d.ts.map +1 -1
  45. package/dist/context/ChatContext.js +1 -0
  46. package/dist/hooks/message/useMessage.d.ts +8 -5
  47. package/dist/hooks/message/useMessage.d.ts.map +1 -1
  48. package/dist/hooks/message/useMessage.js +117 -51
  49. package/dist/hooks/message/useSendMessage.d.ts +2 -4
  50. package/dist/hooks/message/useSendMessage.d.ts.map +1 -1
  51. package/dist/hooks/message/useSendMessage.js +9 -39
  52. package/dist/hooks/search/useSearchMessage.d.ts +232 -0
  53. package/dist/hooks/search/useSearchMessage.d.ts.map +1 -0
  54. package/dist/hooks/search/useSearchMessage.js +71 -0
  55. package/dist/hooks/session/useGetSession.d.ts +222 -0
  56. package/dist/hooks/session/useGetSession.d.ts.map +1 -0
  57. package/dist/hooks/session/useGetSession.js +91 -0
  58. package/dist/hooks/session/useGetSessionSummary.d.ts.map +1 -1
  59. package/dist/hooks/session/useGetSessionSummary.js +2 -1
  60. package/dist/hooks/user/useAuth.d.ts.map +1 -1
  61. package/dist/hooks/user/useAuth.js +6 -4
  62. package/dist/index.d.ts +2 -2
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +2 -1
  65. package/dist/locales/vi/common.json +4 -1
  66. package/dist/screens/deskMessage/index.d.ts.map +1 -1
  67. package/dist/screens/deskMessage/index.js +2 -1
  68. package/dist/services/query.d.ts +1 -1
  69. package/dist/services/query.js +1 -1
  70. package/dist/services/routes.d.ts +1 -1
  71. package/dist/services/routes.js +1 -1
  72. package/dist/store/auth.d.ts.map +1 -1
  73. package/dist/store/auth.js +12 -2
  74. package/dist/store/conversation.d.ts.map +1 -1
  75. package/dist/store/conversation.js +7 -1
  76. package/dist/styles/global.css +1 -1
  77. package/dist/types/chat.d.ts +7 -8
  78. package/dist/types/chat.d.ts.map +1 -1
  79. package/dist/types/chat.js +4 -0
  80. package/dist/types/dto.d.ts +14 -23
  81. package/dist/types/dto.d.ts.map +1 -1
  82. package/dist/utils/common.d.ts +7 -0
  83. package/dist/utils/common.d.ts.map +1 -1
  84. package/dist/utils/common.js +83 -0
  85. package/dist/utils/events.d.ts +1 -0
  86. package/dist/utils/events.d.ts.map +1 -1
  87. package/package.json +3 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ConversationBySessionItem.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/ConversationBySessionItem.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAQpD,UAAU,8BAA8B;IACtC,WAAW,EAAE,gBAAgB,CAAC;CAC/B;AAED,QAAA,MAAM,yBAAyB,GAAI,kBAEhC,8BAA8B,mDAwFhC,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
1
+ {"version":3,"file":"ConversationBySessionItem.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/ConversationBySessionItem.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAQpD,UAAU,8BAA8B;IACtC,WAAW,EAAE,gBAAgB,CAAC;CAC/B;AAED,QAAA,MAAM,yBAAyB,GAAI,kBAEhC,8BAA8B,mDA0FhC,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
@@ -1,18 +1,17 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { MessageType } from "@openim/wasm-client-sdk";
4
3
  import { useTranslation } from "react-i18next";
5
4
  import useConversationStore from "../../store/conversation";
6
5
  import { usePathname, useRouter, useSearchParams } from "next/navigation";
7
6
  import { Avatar, Badge } from "antd";
8
- import { Icon } from "../icon";
9
7
  import { useChatContext } from "../../context/ChatContext";
10
8
  import { useConversationDisplayData } from "../../hooks/conversation/useConversation";
9
+ import { formatTimestamp, parseLatestMessage } from "../../utils/common";
11
10
  const ConversationBySessionItem = ({ sessionItem, }) => {
12
11
  const { t } = useTranslation();
13
12
  const { user } = useChatContext();
14
- const conversation = useConversationStore((state) => state.conversationList.find((conv) => conv.conversationID === sessionItem.conversationId));
15
- const isSelected = useConversationStore((state) => state.selectedConversationId === sessionItem.conversationId);
13
+ const isSelected = useConversationStore((state) => { var _a; return state.selectedConversationId === ((_a = sessionItem === null || sessionItem === void 0 ? void 0 : sessionItem.conversation) === null || _a === void 0 ? void 0 : _a.conversationID); });
14
+ const conversation = sessionItem === null || sessionItem === void 0 ? void 0 : sessionItem.conversation;
16
15
  const router = useRouter();
17
16
  const pathname = usePathname();
18
17
  const searchParams = useSearchParams();
@@ -25,73 +24,11 @@ const ConversationBySessionItem = ({ sessionItem, }) => {
25
24
  router.push(`${pathname}?${newSearchParams.toString()}`);
26
25
  setSelectedConversationId(conversation.conversationID);
27
26
  };
27
+ const { avatar, displayName = "" } = useConversationDisplayData(conversation || null);
28
28
  if (!conversation)
29
29
  return null;
30
- const { avatar, displayName = "" } = useConversationDisplayData(conversation);
31
- return (_jsxs("div", { onClick: () => handleConversationClick(conversation), className: `relative p-3 border-b border-gray-100 hover:bg-gray-50 cursor-pointer transition-colors ${isSelected ? "bg-blue-50" : "bg-white"}`, children: [isSelected && (_jsx("div", { className: "absolute left-0 top-0 bottom-0 w-1 bg-blue-500" })), _jsxs("div", { className: "flex items-start gap-3", children: [_jsx("div", { className: "relative flex-shrink-0", children: _jsx(Badge, { dot: true, status: "success", offset: [-2, 36], children: _jsx(Avatar, { size: 48, src: avatar, alt: displayName, children: displayName.charAt(0).toUpperCase() }) }) }), _jsx("div", { className: "flex-1 min-w-0", children: _jsxs("div", { className: "flex items-start justify-between", children: [_jsxs("div", { className: "flex-1 min-w-0", children: [_jsx("h3", { className: "font-semibold text-gray-900 text-sm truncate", children: displayName }), _jsx("p", { className: "text-xs text-gray-500 truncate mt-0.5", children: parseLatestMessage(conversation.latestMsg, user === null || user === void 0 ? void 0 : user.userID) })] }), _jsxs("div", { className: "flex flex-col items-end gap-1 ml-2", children: [_jsx("span", { className: "text-xs text-gray-400", children: formatTimestamp(conversation.latestMsgSendTime) }), _jsx("div", { className: "flex items-center gap-1", children: conversation.unreadCount > 0 && (_jsx(Badge, { count: conversation.unreadCount })) })] })] }) })] })] }, conversation.conversationID));
30
+ return (_jsxs("div", { onClick: () => handleConversationClick(conversation), className: `relative p-3 border-b border-gray-100 hover:bg-gray-100 cursor-pointer transition-colors ${isSelected ? "bg-blue-50" : "bg-white"}`, children: [isSelected && (_jsx("div", { className: "absolute left-0 top-0 bottom-0 w-1 bg-blue-500" })), _jsxs("div", { className: "flex items-start gap-3", children: [_jsx("div", { className: "relative flex-shrink-0", children: _jsx(Badge, { dot: true, status: "success", offset: [-2, 36], children: _jsx(Avatar, { size: 48, src: avatar, alt: displayName, children: displayName.charAt(0).toUpperCase() }) }) }), _jsx("div", { className: "flex-1 min-w-0", children: _jsxs("div", { className: "flex items-start justify-between", children: [_jsxs("div", { className: "flex-1 min-w-0", children: [_jsx("h3", { className: "font-semibold text-gray-900 text-sm truncate", children: displayName }), _jsx("p", { className: "text-xs text-gray-500 truncate mt-0.5", children: parseLatestMessage(conversation.latestMsg, user === null || user === void 0 ? void 0 : user.userID) })] }), _jsxs("div", { className: "flex flex-col items-end gap-1 ml-2", children: [_jsx("span", { className: "text-xs text-gray-400", children: formatTimestamp(conversation.latestMsgSendTime, {
31
+ hasTime: false,
32
+ }) }), _jsx("div", { className: "flex items-center gap-1", children: conversation.unreadCount > 0 && (_jsx(Badge, { count: conversation.unreadCount })) })] })] }) })] })] }, conversation.conversationID));
32
33
  };
33
34
  export default ConversationBySessionItem;
34
- const parseLatestMessage = (latestMsg, currentUserId) => {
35
- var _a;
36
- if (!latestMsg)
37
- return "";
38
- try {
39
- const msgData = JSON.parse(latestMsg);
40
- const contentType = msgData === null || msgData === void 0 ? void 0 : msgData.contentType;
41
- const isMe = currentUserId && msgData.sendID === currentUserId;
42
- const sender = isMe ? "Me" : (msgData === null || msgData === void 0 ? void 0 : msgData.senderNickname) || msgData.sendID;
43
- switch (contentType) {
44
- case MessageType.TextMessage:
45
- if ((_a = msgData.textElem) === null || _a === void 0 ? void 0 : _a.content) {
46
- return `${sender}: ${msgData.textElem.content}`;
47
- }
48
- break;
49
- case MessageType.PictureMessage:
50
- return (_jsxs("span", { children: [sender, ": ", _jsx(Icon, { icon: "image-o", size: 16, className: "mr-1" }), "H\u00ECnh \u1EA3nh"] }));
51
- case MessageType.VoiceMessage:
52
- return `${sender}: [Tin nhắn thoại]`;
53
- case MessageType.VideoMessage:
54
- return `${sender}: [Video]`;
55
- case MessageType.FileMessage:
56
- return `${sender}: [File đính kèm]`;
57
- default:
58
- return "Tin nhắn không khả dụng";
59
- }
60
- return "Tin nhắn không khả dụng";
61
- }
62
- catch (error) {
63
- console.error("Error parsing latest message:", error);
64
- return "";
65
- }
66
- };
67
- const formatTimestamp = (timestamp) => {
68
- if (!timestamp)
69
- return "";
70
- const date = new Date(timestamp);
71
- const now = new Date();
72
- const diffInMs = now.getTime() - date.getTime();
73
- const diffInDays = Math.floor(diffInMs / (1000 * 60 * 60 * 24));
74
- if (diffInDays === 0) {
75
- // Today - show time
76
- return date.toLocaleTimeString("vi-VN", {
77
- hour: "2-digit",
78
- minute: "2-digit",
79
- hour12: false,
80
- });
81
- }
82
- else if (diffInDays === 1) {
83
- // Yesterday
84
- return "Hôm qua";
85
- }
86
- else if (diffInDays < 7) {
87
- // This week - show day name
88
- return date.toLocaleDateString("vi-VN", { weekday: "long" });
89
- }
90
- else {
91
- // Older - show date
92
- return date.toLocaleDateString("vi-VN", {
93
- day: "2-digit",
94
- month: "2-digit",
95
- });
96
- }
97
- };
@@ -1 +1 @@
1
- {"version":3,"file":"DeskConversationList.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/DeskConversationList.tsx"],"names":[],"mappings":"AAeA,QAAA,MAAM,oBAAoB,+CAkJzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"DeskConversationList.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/DeskConversationList.tsx"],"names":[],"mappings":"AAgBA,QAAA,MAAM,oBAAoB,+CAqKzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -1,33 +1,48 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useState, useEffect, useRef } from "react";
4
- import { useRouter, useSearchParams, usePathname } from "next/navigation";
4
+ import { useSearchParams } from "next/navigation";
5
5
  import { Input, Empty, Drawer, Button, Spin } from "antd";
6
6
  import { Icon } from "../icon";
7
7
  import useConversationStore from "../../store/conversation";
8
8
  import { useTranslation } from "react-i18next";
9
- import { useBoolean, useDebounceFn } from "ahooks";
9
+ import { useBoolean, useDebounce } from "ahooks";
10
10
  import SearchConversation from "../searchConversation";
11
11
  import useSessionStore from "../../store/session";
12
- import { useGetSessionByTagOrStatus } from "../../hooks/session/useGetSessionByTagOrStatus";
13
12
  import InfiniteScroll from "react-infinite-scroll-component";
14
13
  import ConversationBySessionItem from "./ConversationBySessionItem";
14
+ import { useGetSession } from "../../hooks/session/useGetSession";
15
+ import { DChatSDK } from "../../constants/sdk";
15
16
  const DeskConversationList = () => {
17
+ var _a;
16
18
  const searchInputRef = useRef(null);
17
19
  const { t } = useTranslation();
18
20
  const [search, setSearch] = useState("");
19
21
  const [showSearch, { setTrue: setShowSearchTrue, setFalse: setShowSearchFalse },] = useBoolean(false);
20
- const router = useRouter();
21
- const pathname = usePathname();
22
22
  const searchParams = useSearchParams();
23
23
  const setConversationData = useConversationStore((state) => state.setConversationData);
24
24
  const setSelectedConversationId = useConversationStore((state) => state.setSelectedConversationId);
25
25
  const conversationList = useConversationStore((state) => state.conversationList);
26
+ const updateConversationList = useConversationStore((state) => state.updateConversationList);
26
27
  const filterSummary = useSessionStore((state) => state.filterSummary);
27
- const { dataFlatten: sessions, isLoading, error, hasNextPage, fetchNextPage, isFetchingNextPage, } = useGetSessionByTagOrStatus(filterSummary);
28
- const { run: deboundSearch } = useDebounceFn((value) => {
29
- setSearch(value);
30
- }, { wait: 500 });
28
+ const { dataFlatten: sessions, hasNextPage, fetchNextPage, } = useGetSession(filterSummary);
29
+ const debouncedSearch = useDebounce(search, { wait: 500 });
30
+ const onCloseSearch = () => {
31
+ setSearch("");
32
+ setShowSearchFalse();
33
+ setTimeout(() => {
34
+ var _a;
35
+ (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
36
+ }, 500);
37
+ };
38
+ useEffect(() => {
39
+ if (showSearch) {
40
+ setTimeout(() => {
41
+ var _a;
42
+ (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
43
+ }, 100);
44
+ }
45
+ }, [showSearch]);
31
46
  useEffect(() => {
32
47
  const threadId = searchParams.get("threadId");
33
48
  if (threadId) {
@@ -36,22 +51,29 @@ const DeskConversationList = () => {
36
51
  if (selectedConversation) {
37
52
  setConversationData(selectedConversation);
38
53
  }
39
- }
40
- else if (conversationList.length > 0) {
41
- setSelectedConversationId(conversationList[0].conversationID);
42
- setConversationData(conversationList[0]);
43
- const newSearchParams = new URLSearchParams(searchParams);
44
- newSearchParams.set("threadId", conversationList[0].conversationID);
45
- router.replace(`${pathname}?${newSearchParams.toString()}`);
54
+ else {
55
+ DChatSDK.getMultipleConversation([threadId]).then((res) => {
56
+ if (res.data.length > 0) {
57
+ setConversationData(res.data[0]);
58
+ updateConversationList(res.data, "filter");
59
+ }
60
+ });
61
+ }
46
62
  }
47
63
  }, [searchParams, conversationList]);
48
- return (_jsxs("div", { className: `flex flex-col h-full bg-white border-r border-gray-200 w-[320px]`, children: [_jsx("div", { className: "p-3 border-b border-gray-100", children: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Input, { ref: searchInputRef, placeholder: t("search"), prefix: _jsx(Icon, { icon: "search-o", size: 18, className: "text-gray-400" }), onChange: (e) => deboundSearch(e.target.value), className: "rounded-lg text-sm flex-1 h-[36px]", size: "large", allowClear: true, onClick: setShowSearchTrue }), showSearch && (_jsx(Button, { onClick: setShowSearchFalse, variant: "outlined", className: "p-0 w-[36px] h-[36px] text-gray-500", children: _jsx(Icon, { icon: "close-b", size: 22 }) }))] }) }), _jsx("div", { id: "scrollableDiv", style: {
64
+ return (_jsxs("div", { className: `flex flex-col h-full bg-white border-r border-gray-200 w-[320px]`, children: [_jsx("div", { className: "p-3 border-b border-gray-100", children: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Input, { ref: searchInputRef, placeholder: t("search"), prefix: _jsx(Icon, { icon: "search-o", size: 18, className: "text-gray-400" }), onChange: (e) => {
65
+ if (!showSearch && e.target.value) {
66
+ setShowSearchTrue();
67
+ }
68
+ setSearch(e.target.value);
69
+ }, className: "rounded-lg text-sm flex-1 h-[36px]", size: "large", allowClear: true, onClick: setShowSearchTrue, value: search, autoFocus: false, onClear: onCloseSearch }), showSearch && (_jsx(Button, { onClick: onCloseSearch, variant: "outlined", className: "p-0 w-[36px] h-[36px] text-gray-500", children: _jsx(Icon, { icon: "close-b", size: 22 }) }))] }) }), _jsxs("div", { id: "scrollableConversationsDiv", style: {
49
70
  height: "100%",
50
71
  overflow: "auto",
51
- }, children: _jsxs(InfiniteScroll, { dataLength: (sessions === null || sessions === void 0 ? void 0 : sessions.length) || 0, next: fetchNextPage, hasMore: hasNextPage, loader: _jsx("div", { className: "flex items-center justify-center py-2", children: _jsx(Spin, {}) }), scrollableTarget: "scrollableDiv", children: [(sessions === null || sessions === void 0 ? void 0 : sessions.length) === 0 && (_jsx("div", { className: "flex items-center justify-center py-12", children: _jsx(Empty, { image: _jsx(Icon, { icon: "chat-square-b", size: 80, className: "text-gray-300" }), description: t("no_conversation") }) })), sessions === null || sessions === void 0 ? void 0 : sessions.map((session) => (_jsx(ConversationBySessionItem, { sessionItem: session }, session.conversationId)))] }) }), _jsx(Drawer, { open: showSearch, mask: false, closeIcon: false, styles: {
52
- body: {
53
- padding: 0,
54
- },
55
- }, getContainer: false, width: "100%", children: _jsx(SearchConversation, {}) })] }));
72
+ position: "relative",
73
+ }, children: [_jsx(InfiniteScroll, { dataLength: (sessions === null || sessions === void 0 ? void 0 : sessions.length) || 0, next: fetchNextPage, hasMore: hasNextPage, loader: _jsx("div", { className: "flex items-center justify-center py-2", children: _jsx(Spin, {}) }), scrollableTarget: "scrollableConversationsDiv", children: (sessions === null || sessions === void 0 ? void 0 : sessions.length) === 0 ? (_jsx("div", { className: "flex items-center justify-center py-12", children: _jsx(Empty, { image: _jsx(Icon, { icon: "chat-square-b", size: 80, className: "text-gray-300" }), description: t("no_conversation") }) })) : ((_a = sessions === null || sessions === void 0 ? void 0 : sessions.map) === null || _a === void 0 ? void 0 : _a.call(sessions, (session) => (_jsx(ConversationBySessionItem, { sessionItem: session }, session.conversationId)))) }), _jsx(Drawer, { open: showSearch, mask: false, closeIcon: false, styles: {
74
+ body: {
75
+ padding: 0,
76
+ },
77
+ }, getContainer: false, width: "100%", children: _jsx(SearchConversation, { searchTerm: debouncedSearch }) })] })] }));
56
78
  };
57
79
  export default DeskConversationList;
@@ -1 +1 @@
1
- {"version":3,"file":"FileCollection.d.ts","sourceRoot":"","sources":["../../../src/components/mediaCollection/FileCollection.tsx"],"names":[],"mappings":"AAcA,QAAA,MAAM,cAAc,+CA4GnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"FileCollection.d.ts","sourceRoot":"","sources":["../../../src/components/mediaCollection/FileCollection.tsx"],"names":[],"mappings":"AAcA,QAAA,MAAM,cAAc,+CAqGnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { MessageType } from "@openim/wasm-client-sdk";
3
- import { useMediaCollection } from "../../hooks/collection/useMediaCollection";
3
+ import { useSearchMessage } from "../../hooks/search/useSearchMessage";
4
4
  import InfiniteScroll from "react-infinite-scroll-component";
5
5
  import { Empty, Spin } from "antd";
6
6
  import { useCallback } from "react";
@@ -10,13 +10,14 @@ import { useTranslation } from "react-i18next";
10
10
  import { documentIcon } from "../../assets/svg";
11
11
  import { shortenFileName } from "../message/footer/FilePreview";
12
12
  import { renderFileSize } from "../../utils/common";
13
- import { TOP_OFFSET } from ".";
14
13
  const FileCollection = () => {
15
14
  const { t } = useTranslation();
16
15
  const selectedSourceId = useConversationStore((state) => state.selectedSourceId);
17
- const { groupedData, fetchNextPage, hasNextPage, dataFlatten, isLoading } = useMediaCollection({
18
- recvID: selectedSourceId,
19
- contentType: MessageType.FileMessage,
16
+ const { groupedData, fetchNextPage, hasNextPage, dataFlatten, isLoading } = useSearchMessage({
17
+ payload: {
18
+ recvID: selectedSourceId,
19
+ contentType: MessageType.FileMessage,
20
+ },
20
21
  });
21
22
  const handleDownload = (url, fileName) => {
22
23
  if (!url) {
@@ -47,6 +48,6 @@ const FileCollection = () => {
47
48
  return _jsx(Empty, { description: t("no_media_files") });
48
49
  if (isLoading)
49
50
  return (_jsx("div", { className: "flex items-center justify-center", children: _jsx(Spin, {}) }));
50
- return (_jsx("div", { id: "scrollableFileDiv", className: "h-full overflow-auto", style: { maxHeight: `calc(100vh - ${TOP_OFFSET}px)` }, children: _jsx(InfiniteScroll, { dataLength: Object.keys(groupedData).length, next: fetchNextPage, hasMore: hasNextPage, loader: _jsx("div", { className: "flex items-center justify-center py-2", children: _jsx(Spin, {}) }), scrollableTarget: "scrollableFileDiv", children: Object.entries(groupedData).map(([date, items]) => renderItem(date, items)) }) }));
51
+ return (_jsx("div", { id: "scrollableFileDiv", className: "h-full overflow-auto", children: _jsx(InfiniteScroll, { dataLength: Object.keys(groupedData).length, next: fetchNextPage, hasMore: hasNextPage, loader: _jsx("div", { className: "flex items-center justify-center py-2", children: _jsx(Spin, {}) }), scrollableTarget: "scrollableFileDiv", children: Object.entries(groupedData).map(([date, items]) => renderItem(date, items)) }) }));
51
52
  };
52
53
  export default FileCollection;
@@ -1 +1 @@
1
- {"version":3,"file":"ImageCollection.d.ts","sourceRoot":"","sources":["../../../src/components/mediaCollection/ImageCollection.tsx"],"names":[],"mappings":"AAaA,QAAA,MAAM,eAAe,+CAoHpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"ImageCollection.d.ts","sourceRoot":"","sources":["../../../src/components/mediaCollection/ImageCollection.tsx"],"names":[],"mappings":"AAaA,QAAA,MAAM,eAAe,+CA+GpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { MessageType } from "@openim/wasm-client-sdk";
3
- import { useMediaCollection } from "../../hooks/collection/useMediaCollection";
3
+ import { useSearchMessage } from "../../hooks/search/useSearchMessage";
4
4
  import InfiniteScroll from "react-infinite-scroll-component";
5
5
  import { Button, Empty, Image, Spin } from "antd";
6
6
  import { useCallback } from "react";
@@ -8,14 +8,15 @@ import dayjs from "dayjs";
8
8
  import useConversationStore from "../../store/conversation";
9
9
  import { images } from "../../constants/images";
10
10
  import { useTranslation } from "react-i18next";
11
- import { TOP_OFFSET } from ".";
12
11
  import { DownloadOutlined } from "@ant-design/icons";
13
12
  const ImageCollection = () => {
14
13
  const { t } = useTranslation();
15
14
  const selectedSourceId = useConversationStore((state) => state.selectedSourceId);
16
- const { groupedData, fetchNextPage, hasNextPage, dataFlatten, isLoading } = useMediaCollection({
17
- recvID: selectedSourceId,
18
- contentType: MessageType.PictureMessage,
15
+ const { groupedData, fetchNextPage, hasNextPage, dataFlatten, isLoading } = useSearchMessage({
16
+ payload: {
17
+ recvID: selectedSourceId,
18
+ contentType: MessageType.PictureMessage,
19
+ },
19
20
  });
20
21
  const handleDownload = (imageUrl) => {
21
22
  if (!imageUrl)
@@ -40,7 +41,7 @@ const ImageCollection = () => {
40
41
  return _jsx(Empty, { description: t("no_media_files") });
41
42
  if (isLoading)
42
43
  return (_jsx("div", { className: "flex items-center justify-center", children: _jsx(Spin, {}) }));
43
- return (_jsx("div", { id: "scrollableImageDiv", className: "h-full overflow-auto", style: { maxHeight: `calc(100vh - ${TOP_OFFSET}px)` }, children: _jsx(Image.PreviewGroup, { preview: {
44
+ return (_jsx("div", { id: "scrollableImageDiv", className: "h-full overflow-auto", children: _jsx(Image.PreviewGroup, { preview: {
44
45
  toolbarRender: (originalNode, info) => {
45
46
  var _a;
46
47
  const imageUrl = (_a = info === null || info === void 0 ? void 0 : info.image) === null || _a === void 0 ? void 0 : _a.url;
@@ -1 +1 @@
1
- {"version":3,"file":"VideoCollection.d.ts","sourceRoot":"","sources":["../../../src/components/mediaCollection/VideoCollection.tsx"],"names":[],"mappings":"AAcA,QAAA,MAAM,eAAe,+CA8HpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"VideoCollection.d.ts","sourceRoot":"","sources":["../../../src/components/mediaCollection/VideoCollection.tsx"],"names":[],"mappings":"AAcA,QAAA,MAAM,eAAe,+CAyHpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { MessageType } from "@openim/wasm-client-sdk";
3
- import { useMediaCollection } from "../../hooks/collection/useMediaCollection";
3
+ import { useSearchMessage } from "../../hooks/search/useSearchMessage";
4
4
  import InfiniteScroll from "react-infinite-scroll-component";
5
5
  import { Carousel, Empty, Image, Modal, Spin } from "antd";
6
6
  import { useCallback, useState } from "react";
@@ -10,13 +10,14 @@ import { useBoolean } from "ahooks";
10
10
  import { images } from "../../constants/images";
11
11
  import { Icon } from "../icon";
12
12
  import { useTranslation } from "react-i18next";
13
- import { TOP_OFFSET } from ".";
14
13
  const VideoCollection = () => {
15
14
  const { t } = useTranslation();
16
15
  const selectedSourceId = useConversationStore((state) => state.selectedSourceId);
17
- const { groupedData, fetchNextPage, hasNextPage, dataFlatten, isLoading } = useMediaCollection({
18
- recvID: selectedSourceId,
19
- contentType: MessageType.VideoMessage,
16
+ const { groupedData, fetchNextPage, hasNextPage, dataFlatten, isLoading } = useSearchMessage({
17
+ payload: {
18
+ recvID: selectedSourceId,
19
+ contentType: MessageType.VideoMessage,
20
+ },
20
21
  });
21
22
  const [open, { setTrue, setFalse }] = useBoolean(false);
22
23
  const [currentIndex, setCurrentIndex] = useState(0);
@@ -36,7 +37,7 @@ const VideoCollection = () => {
36
37
  return _jsx(Empty, { description: t("no_media_files") });
37
38
  if (isLoading)
38
39
  return (_jsx("div", { className: "flex items-center justify-center", children: _jsx(Spin, {}) }));
39
- return (_jsxs("div", { id: "scrollableVideoDiv", className: "h-full overflow-auto", style: { maxHeight: `calc(100vh - ${TOP_OFFSET}px)` }, children: [_jsx(InfiniteScroll, { dataLength: Object.keys(groupedData).length, next: fetchNextPage, hasMore: hasNextPage, loader: _jsx("div", { className: "flex items-center justify-center py-2", children: _jsx(Spin, {}) }), scrollableTarget: "scrollableVideoDiv", children: Object.entries(groupedData).map(([date, items]) => renderItem(date, items)) }), _jsx(Modal, { open: open, onCancel: setFalse, footer: null, centered: true, styles: {
40
+ return (_jsxs("div", { id: "scrollableVideoDiv", className: "h-full overflow-auto", children: [_jsx(InfiniteScroll, { dataLength: Object.keys(groupedData).length, next: fetchNextPage, hasMore: hasNextPage, loader: _jsx("div", { className: "flex items-center justify-center py-2", children: _jsx(Spin, {}) }), scrollableTarget: "scrollableVideoDiv", children: Object.entries(groupedData).map(([date, items]) => renderItem(date, items)) }), _jsx(Modal, { open: open, onCancel: setFalse, footer: null, centered: true, styles: {
40
41
  content: {
41
42
  padding: 0,
42
43
  },
@@ -28,26 +28,26 @@ const MediaCollection = () => {
28
28
  return [
29
29
  {
30
30
  key: MediaCollectionTabKey.Image,
31
- label: "Ảnh",
31
+ label: t("image"),
32
32
  children: _jsx(ImageCollection, {}),
33
33
  },
34
34
  {
35
35
  key: MediaCollectionTabKey.Video,
36
- label: "Video",
36
+ label: t("video"),
37
37
  children: _jsx(VideoCollection, {}),
38
38
  },
39
39
  {
40
40
  key: MediaCollectionTabKey.File,
41
- label: "Tập tin",
41
+ label: t("file"),
42
42
  children: _jsx(FileCollection, {}),
43
43
  },
44
44
  {
45
45
  key: MediaCollectionTabKey.Link,
46
- label: "Liên kết",
46
+ label: t("link"),
47
47
  children: _jsx(LinkCollection, {}),
48
48
  },
49
49
  ];
50
- }, [isOpen]);
50
+ }, [isOpen, t]);
51
51
  return (_jsxs(_Fragment, { children: [_jsx(Button, { type: "text", shape: "default", className: "text-gray-500 w-8 h-8 p-0", onClick: toggle, children: _jsx(Icon, { icon: "folder-o", size: 22 }) }), _jsx(Drawer, { open: isOpen, onClose: toggle, mask: false, closeIcon: false, styles: {
52
52
  body: {
53
53
  padding: 0,
@@ -1,5 +1,6 @@
1
1
  interface MessageListProps {
2
2
  conversationId: string;
3
+ searchClientMsgID?: string;
3
4
  className?: string;
4
5
  onClose?: () => void;
5
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../src/components/message/MessageList.tsx"],"names":[],"mappings":"AAiBA,UAAU,gBAAgB;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,QAAA,MAAM,WAAW,GAAI,OAAO,gBAAgB,4CA0F3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../src/components/message/MessageList.tsx"],"names":[],"mappings":"AAsBA,UAAU,gBAAgB;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAGD,QAAA,MAAM,WAAW,GAAI,OAAO,gBAAgB,4CA0K3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useMessage } from "../../hooks/message/useMessage";
4
4
  import { Empty, Spin } from "antd";
5
- import { useEffect, useMemo, useRef } from "react";
5
+ import { useEffect, useRef } from "react";
6
6
  import dayjs from "dayjs";
7
7
  import isToday from "dayjs/plugin/isToday";
8
8
  import emitter from "../../utils/events";
@@ -13,37 +13,82 @@ import MessageFooter from "./footer";
13
13
  import { images } from "../../constants/images";
14
14
  import { useTranslation } from "react-i18next";
15
15
  import useConversationStore from "../../store/conversation";
16
+ import { isNumber } from "lodash";
17
+ import { useDebounceFn } from "ahooks";
18
+ import { MSG_ITEM_CONTENT_PREFIX, MSG_ITEM_PREFIX } from "../../constants";
19
+ import { markConversationMessageAsRead } from "../../hooks/conversation/useConversation";
20
+ import { useChatContext } from "../../context/ChatContext";
16
21
  dayjs.extend(isToday);
22
+ const BOTTOM_THRESHOLD = -5;
17
23
  const MessageList = (props) => {
18
- var _a, _b, _c;
24
+ var _a;
19
25
  const { t } = useTranslation();
20
- const { onClose, conversationId } = props;
26
+ const { user } = useChatContext();
27
+ const { onClose, conversationId, searchClientMsgID } = props;
21
28
  const scrollRef = useRef(null);
22
- const { getMoreOldMessages, moreOldLoading, loadState, latestLoadState } = useMessage(conversationId);
29
+ const { getMoreOldMessages, moreOldLoading, loadState, getMoreNewMessages, moreNewLoading, latestLoadState, } = useMessage(conversationId, searchClientMsgID);
23
30
  const conversationData = useConversationStore((state) => state.conversationData);
24
- const lastMessage = useMemo(() => {
25
- var _a;
26
- const messageList = (_a = latestLoadState.current) === null || _a === void 0 ? void 0 : _a.messageList;
27
- return messageList === null || messageList === void 0 ? void 0 : messageList[(messageList === null || messageList === void 0 ? void 0 : messageList.length) - 1];
28
- }, [(_a = latestLoadState === null || latestLoadState === void 0 ? void 0 : latestLoadState.current) === null || _a === void 0 ? void 0 : _a.messageList]);
31
+ const handleMarkConversationMessageAsRead = () => {
32
+ var _a, _b, _c;
33
+ const lastMessage = (_b = (_a = latestLoadState === null || latestLoadState === void 0 ? void 0 : latestLoadState.current) === null || _a === void 0 ? void 0 : _a.messageList) === null || _b === void 0 ? void 0 : _b[0];
34
+ if (!((_c = latestLoadState === null || latestLoadState === void 0 ? void 0 : latestLoadState.current) === null || _c === void 0 ? void 0 : _c.hasMoreNew) &&
35
+ !moreNewLoading &&
36
+ (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.isRead) === false &&
37
+ (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.sendID) !== (user === null || user === void 0 ? void 0 : user.userID)) {
38
+ markConversationMessageAsRead(conversationId);
39
+ }
40
+ };
29
41
  const scrollToBottom = () => {
42
+ handleMarkConversationMessageAsRead();
30
43
  setTimeout(() => {
31
- var _a, _b;
32
- (_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({
33
- top: (_b = scrollRef.current) === null || _b === void 0 ? void 0 : _b.scrollHeight,
44
+ var _a, _b, _c, _d;
45
+ if (isNumber((_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTop) &&
46
+ ((_b = scrollRef.current) === null || _b === void 0 ? void 0 : _b.scrollTop) >= BOTTOM_THRESHOLD) {
47
+ return;
48
+ }
49
+ (_c = scrollRef.current) === null || _c === void 0 ? void 0 : _c.scrollTo({
50
+ top: (_d = scrollRef.current) === null || _d === void 0 ? void 0 : _d.scrollHeight,
34
51
  behavior: "smooth",
35
52
  });
36
53
  });
37
54
  };
38
- const loadMoreMessage = () => {
55
+ const scrollToMessage = (clientMsgID) => {
56
+ setTimeout(() => {
57
+ const targetElement = document.getElementById(`${MSG_ITEM_PREFIX}${clientMsgID}`);
58
+ targetElement === null || targetElement === void 0 ? void 0 : targetElement.scrollIntoView({
59
+ behavior: "auto",
60
+ block: "center",
61
+ });
62
+ setTimeout(() => {
63
+ const targetContentElement = document.getElementById(`${MSG_ITEM_CONTENT_PREFIX}${clientMsgID}`);
64
+ targetContentElement === null || targetContentElement === void 0 ? void 0 : targetContentElement.classList.add("zoom-in-out-element", "border-blue-500", "border");
65
+ // Khi animation kết thúc thì remove element
66
+ const onEnd = () => {
67
+ targetContentElement === null || targetContentElement === void 0 ? void 0 : targetContentElement.classList.remove("zoom-in-out-element", "border-blue-500", "border");
68
+ targetContentElement === null || targetContentElement === void 0 ? void 0 : targetContentElement.removeEventListener("animationend", onEnd);
69
+ };
70
+ targetContentElement === null || targetContentElement === void 0 ? void 0 : targetContentElement.addEventListener("animationend", onEnd, {
71
+ once: true,
72
+ });
73
+ }, 500);
74
+ }, 200);
75
+ };
76
+ const loadMoreOldMessage = () => {
39
77
  if (!loadState.hasMoreOld || moreOldLoading)
40
78
  return;
41
79
  getMoreOldMessages();
42
80
  };
81
+ const { run: loadMoreNewMessage } = useDebounceFn(() => {
82
+ if (!loadState.hasMoreNew || moreNewLoading)
83
+ return;
84
+ getMoreNewMessages();
85
+ }, { wait: 200 });
43
86
  useEffect(() => {
44
87
  emitter.on("CHAT_LIST_SCROLL_TO_BOTTOM", scrollToBottom);
88
+ emitter.on("CHAT_LIST_SCROLL_TO_MESSAGE", scrollToMessage);
45
89
  return () => {
46
90
  emitter.off("CHAT_LIST_SCROLL_TO_BOTTOM", scrollToBottom);
91
+ emitter.off("CHAT_LIST_SCROLL_TO_MESSAGE", scrollToMessage);
47
92
  };
48
93
  }, []);
49
94
  if (!conversationData) {
@@ -53,11 +98,18 @@ const MessageList = (props) => {
53
98
  backgroundImage: `url(${images.conversationBg})`,
54
99
  backgroundSize: "cover",
55
100
  backgroundPosition: "center",
56
- }, children: [_jsx(MessageHeader, { onClose: onClose }), _jsx("div", { id: "scrollableDiv", style: {
101
+ }, children: [_jsx(MessageHeader, { onClose: onClose }), _jsx("div", { id: "scrollableMessagesDiv", ref: scrollRef, style: {
57
102
  height: "100%",
58
103
  overflow: "auto",
59
104
  display: "flex",
60
105
  flexDirection: "column-reverse",
61
- }, children: _jsx(InfiniteScroll, { dataLength: ((_b = loadState.groupMessageList) === null || _b === void 0 ? void 0 : _b.length) || 0, next: loadMoreMessage, style: { display: "flex", flexDirection: "column-reverse" }, inverse: true, hasMore: loadState.hasMoreOld, loader: _jsx("div", { className: "flex items-center justify-center py-2", children: _jsx(Spin, {}) }), scrollableTarget: "scrollableDiv", children: (_c = loadState.groupMessageList) === null || _c === void 0 ? void 0 : _c.toReversed().map((message) => (_jsx(MessageItem, { groupMessage: message }, message.groupMessageID))) }) }), _jsx(MessageFooter, { lastMessage: lastMessage })] }));
106
+ paddingBottom: 12,
107
+ }, children: _jsx(InfiniteScroll, { dataLength: ((_a = loadState.messageList) === null || _a === void 0 ? void 0 : _a.length) || 0, next: loadMoreOldMessage, style: { display: "flex", flexDirection: "column-reverse" }, inverse: true, hasMore: loadState.hasMoreOld, loader: _jsx("div", { className: "flex items-center justify-center py-2", children: _jsx(Spin, {}) }), scrollableTarget: "scrollableMessagesDiv", onScroll: (e) => {
108
+ const target = e.target;
109
+ if (target.scrollTop > BOTTOM_THRESHOLD) {
110
+ handleMarkConversationMessageAsRead();
111
+ loadMoreNewMessage();
112
+ }
113
+ }, children: loadState.messageList.map((message, _, array) => (_jsx(MessageItem, { message: message, allMessages: array }, message.clientMsgID))) }) }), moreNewLoading && (_jsx("div", { className: "flex items-center justify-center py-2", children: _jsx(Spin, {}) })), _jsx(MessageFooter, {})] }));
62
114
  };
63
115
  export default MessageList;
@@ -1,10 +1,6 @@
1
1
  import { MessageFooterContextType } from "../../../types/chat";
2
- import { MessageItem } from "@openim/wasm-client-sdk";
3
- interface IMessageFooterProviderProps {
4
- lastMessage?: MessageItem;
5
- }
6
2
  export declare const MessageFooterContext: import("react").Context<MessageFooterContextType>;
7
3
  export declare const useMessageFooterContext: () => MessageFooterContextType;
8
- declare const MessageFooterProvider: (props: IMessageFooterProviderProps) => import("react/jsx-runtime").JSX.Element;
4
+ declare const MessageFooterProvider: () => import("react/jsx-runtime").JSX.Element;
9
5
  export default MessageFooterProvider;
10
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/message/footer/index.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAKtD,UAAU,2BAA2B;IACnC,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AA+BD,eAAO,MAAM,oBAAoB,mDAI/B,CAAC;AAEH,eAAO,MAAM,uBAAuB,gCAAyC,CAAC;AAE9E,QAAA,MAAM,qBAAqB,GAAI,OAAO,2BAA2B,4CAuDhE,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/message/footer/index.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAmC/D,eAAO,MAAM,oBAAoB,mDAI/B,CAAC;AAEH,eAAO,MAAM,uBAAuB,gCAAyC,CAAC;AAE9E,QAAA,MAAM,qBAAqB,+CAuD1B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -15,6 +15,7 @@ import EnterHandler from "./EnterHandler";
15
15
  import ActionBar from "./ActionBar";
16
16
  import { useSendMessage } from "../../../hooks/message/useSendMessage";
17
17
  import FilePreview from "./FilePreview";
18
+ import { useTranslation } from "react-i18next";
18
19
  const theme = {
19
20
  text: {
20
21
  bold: "font-bold",
@@ -47,9 +48,9 @@ export const MessageFooterContext = createContext({
47
48
  setListUploadFiles: () => { },
48
49
  });
49
50
  export const useMessageFooterContext = () => useContext(MessageFooterContext);
50
- const MessageFooterProvider = (props) => {
51
- const { lastMessage } = props;
52
- const { sendTextMessage, sendMergeMessage } = useSendMessage(lastMessage);
51
+ const MessageFooterProvider = () => {
52
+ const { t } = useTranslation();
53
+ const { sendTextMessage, sendMergeMessage } = useSendMessage();
53
54
  const [listUploadFiles, setListUploadFiles] = useState([]);
54
55
  const onSendMessage = useCallback(async ({ plainText, richText, type, }) => {
55
56
  if (type === "text") {
@@ -60,6 +61,6 @@ const MessageFooterProvider = (props) => {
60
61
  }
61
62
  setListUploadFiles([]);
62
63
  }, [sendMergeMessage, sendTextMessage, listUploadFiles]);
63
- return (_jsx(MessageFooterContext.Provider, { value: { onSendMessage, listUploadFiles, setListUploadFiles }, children: _jsxs(LexicalComposer, { initialConfig: initialConfig, children: [_jsxs("div", { className: "border-t pb-2 flex flex-col gap-1 bg-white", children: [listUploadFiles.length > 0 && _jsx(FilePreview, {}), _jsx(ToolbarPlugin, {}), _jsx("div", { className: "relative px-4", children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "border border-indigo-500 rounded-md bg-blue-100 min-h-[64px] max-h-[140px] overflow-y-auto px-3 py-2 text-sm" }), ErrorBoundary: LexicalErrorBoundary, "aria-placeholder": "Nh\u1EADp tin nh\u1EAFn", placeholder: _jsx("div", { className: "absolute top-2 left-7 pointer-events-none", children: _jsx("p", { className: "text-gray-500 text-sm", children: "Nh\u1EADp tin nh\u1EAFn" }) }) }) }), _jsx(ActionBar, {})] }), _jsx(LinkPlugin, {}), _jsx(ListPlugin, {}), _jsx(EnterHandler, {})] }) }));
64
+ return (_jsx(MessageFooterContext.Provider, { value: { onSendMessage, listUploadFiles, setListUploadFiles }, children: _jsxs(LexicalComposer, { initialConfig: initialConfig, children: [_jsxs("div", { className: "border-t pb-2 flex flex-col gap-1 bg-white", children: [listUploadFiles.length > 0 && _jsx(FilePreview, {}), _jsx(ToolbarPlugin, {}), _jsx("div", { className: "relative px-4", children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "border border-indigo-500 rounded-md bg-blue-100 min-h-[64px] max-h-[140px] overflow-y-auto px-3 py-2 text-sm" }), ErrorBoundary: LexicalErrorBoundary, "aria-placeholder": t("enter_message"), placeholder: _jsx("div", { className: "absolute top-2 left-7 pointer-events-none", children: _jsx("p", { className: "text-gray-500 text-sm", children: t("enter_message") }) }) }) }), _jsx(ActionBar, {})] }), _jsx(LinkPlugin, {}), _jsx(ListPlugin, {}), _jsx(EnterHandler, {})] }) }));
64
65
  };
65
66
  export default MessageFooterProvider;
@@ -1,7 +1,8 @@
1
- import { GroupMessageItem } from "../../../types/chat";
1
+ import { MessageItem as MessageItemType } from "@openim/wasm-client-sdk";
2
2
  interface MessageItemProps {
3
- groupMessage: GroupMessageItem;
3
+ message: MessageItemType;
4
+ allMessages: MessageItemType[];
4
5
  }
5
- declare const MessageItem: ({ groupMessage }: MessageItemProps) => import("react/jsx-runtime").JSX.Element | null;
6
+ declare const MessageItem: ({ message, allMessages }: MessageItemProps) => import("react/jsx-runtime").JSX.Element | null;
6
7
  export default MessageItem;
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAkBvD,UAAU,gBAAgB;IACxB,YAAY,EAAE,gBAAgB,CAAC;CAChC;AAiBD,QAAA,MAAM,WAAW,GAAI,kBAAkB,gBAAgB,mDA2GtD,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,WAAW,IAAI,eAAe,EAE/B,MAAM,yBAAyB,CAAC;AAYjC,UAAU,gBAAgB;IACxB,OAAO,EAAE,eAAe,CAAC;IACzB,WAAW,EAAE,eAAe,EAAE,CAAC;CAChC;AAID,QAAA,MAAM,WAAW,GAAI,0BAA0B,gBAAgB,mDAgH9D,CAAC;AAEF,eAAe,WAAW,CAAC"}