@pubuduth-aplicy/chat-ui 2.1.11 → 2.1.13

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.11",
3
+ "version": "2.1.13",
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": "",
@@ -11,9 +11,11 @@ import useChatUIStore from "../../stores/Zustant";
11
11
  const Messages = () => {
12
12
  const { selectedConversation } = useChatUIStore()
13
13
  const {userId}=useChatContext()
14
- const { data: messages } = useMessages(selectedConversation?._id,userId);
14
+ const { data: messages, isLoading, isError, error } = useMessages(selectedConversation?._id, userId);
15
15
  // useListenMessages();
16
- console.log(messages);
16
+ console.log("isLoading",isLoading);
17
+ console.log("error",error);
18
+ console.log("messages",messages);
17
19
 
18
20
  const lastMessageRef = useRef<HTMLDivElement>(null);
19
21
 
@@ -15,8 +15,12 @@ export const useGetConversations = (id: any) => {
15
15
  });
16
16
  };
17
17
 
18
- export const useMessages = (chatId: string,userid:string) => {
18
+ export const useMessages = (chatId: string, userid: string) => {
19
19
  return useQuery({
20
- queryKey:['messages', chatId,userid],
21
- queryFn: () => fetchMessages(chatId,userid)});
22
- };
20
+ queryKey: ['messages', chatId, userid],
21
+ queryFn: () => {
22
+ console.log('Fetching messages for:', chatId, userid);
23
+ return fetchMessages(chatId, userid);
24
+ },
25
+ });
26
+ };
@@ -10,7 +10,13 @@ export const sendMessage = async ({ chatId, message }: { chatId: any; message: s
10
10
  };
11
11
 
12
12
 
13
- export const fetchMessages = async (chatId: string,userid:string) => {
14
- const response = await apiClient.get(`${Path.getmessage}/${chatId}/${userid}`);
15
- return response.data();
13
+ export const fetchMessages = async (chatId: string, userid: string) => {
14
+ try {
15
+ const response = await apiClient.get(`${Path.getmessage}/${chatId}/${userid}`);
16
+ console.log(response); // Check the full response
17
+ return response.data; // Ensure 'data' exists or adjust accordingly
18
+ } catch (error) {
19
+ console.error("Error fetching messages:", error);
20
+ return []; // Return a default empty array on error
21
+ }
16
22
  };