@pubuduth-aplicy/chat-ui 2.1.8 → 2.1.10
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubuduth-aplicy/chat-ui",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.10",
|
|
4
4
|
"description": "This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
29
29
|
"eslint-plugin-react-refresh": "^0.4.19",
|
|
30
30
|
"globals": "^15.15.0",
|
|
31
|
-
"typescript": "
|
|
31
|
+
"typescript": "^5.8.2",
|
|
32
32
|
"typescript-eslint": "^8.24.1",
|
|
33
33
|
"vite": "^6.2.0"
|
|
34
34
|
}
|
|
@@ -6,7 +6,7 @@ import useChatUIStore from '../../stores/Zustant';
|
|
|
6
6
|
// import useSendMessage from '../../hooks/useSendMessage'; // Importing the useSendMessage hook
|
|
7
7
|
|
|
8
8
|
const MessageInput = () => {
|
|
9
|
-
const { socket
|
|
9
|
+
const { socket } = useChatContext();
|
|
10
10
|
const { selectedConversation } = useChatUIStore();
|
|
11
11
|
const [message, setMessage] = useState(""); // State for storing the message input
|
|
12
12
|
const { mutate: sendMessage } = useMessageMutation();
|
|
@@ -15,8 +15,13 @@ const MessageInput = () => {
|
|
|
15
15
|
e.preventDefault();
|
|
16
16
|
if (!message)
|
|
17
17
|
return;
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
if (selectedConversation?._id) {
|
|
19
|
+
// Send message
|
|
20
|
+
sendMessage({ chatId:selectedConversation._id, message });
|
|
21
|
+
|
|
22
|
+
// Emit message to socket
|
|
23
|
+
socket.emit('sendMessage', { chatId: selectedConversation._id, message });
|
|
24
|
+
}
|
|
20
25
|
setMessage("");
|
|
21
26
|
};
|
|
22
27
|
|
|
@@ -5,9 +5,14 @@ import useChatUIStore from "../../stores/Zustant";
|
|
|
5
5
|
|
|
6
6
|
interface ConversationProps {
|
|
7
7
|
conversation: {
|
|
8
|
-
|
|
8
|
+
participantDetails:{
|
|
9
|
+
_id: string;
|
|
9
10
|
profilePic: string;
|
|
10
|
-
|
|
11
|
+
firstname: string;
|
|
12
|
+
idpic:string;
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
_id:string;
|
|
11
16
|
};
|
|
12
17
|
lastIdx: boolean;
|
|
13
18
|
}
|
|
@@ -28,12 +33,12 @@ console.log(conversation);
|
|
|
28
33
|
>
|
|
29
34
|
<img
|
|
30
35
|
className="w-12 h-12 relative rounded-[100px]"
|
|
31
|
-
src={conversation.profilePic|| conversation.idpic}
|
|
36
|
+
src={conversation.participantDetails.profilePic|| conversation.participantDetails.idpic}
|
|
32
37
|
/>
|
|
33
38
|
<div className="grow shrink basis-0 flex-col justify-start items-start gap-1 inline-flex">
|
|
34
39
|
<div className="self-stretch justify-start items-center inline-flex">
|
|
35
40
|
<div className="grow shrink basis-0 text-slate-900 text-base font-semibold font-['Inter'] leading-tight">
|
|
36
|
-
{conversation.firstname}
|
|
41
|
+
{conversation.participantDetails.firstname}
|
|
37
42
|
</div>
|
|
38
43
|
</div>
|
|
39
44
|
</div>
|
package/src/stores/Zustant.ts
CHANGED
|
@@ -12,9 +12,13 @@ interface ChatUIState {
|
|
|
12
12
|
isChatOpen: boolean;
|
|
13
13
|
unreadCount: number;
|
|
14
14
|
selectedConversation: {
|
|
15
|
-
|
|
15
|
+
participantDetails:{
|
|
16
|
+
_id: string;
|
|
16
17
|
profilePic: string;
|
|
17
|
-
|
|
18
|
+
firstname: string;
|
|
19
|
+
idpic:string;
|
|
20
|
+
}
|
|
21
|
+
_id:string;
|
|
18
22
|
} | null;
|
|
19
23
|
setSelectedConversation: (selectedConversation: { _id: string; profilePic: string; username: string; } | null) => void;
|
|
20
24
|
toggleChat: () => void;
|
package/src/vite-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|