Skip to content

Commit

Permalink
chating error fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
thakiyudheen committed Jul 17, 2024
1 parent dce9e11 commit 2d27e1b
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 128 deletions.
26 changes: 13 additions & 13 deletions src/Components/common/skelton/loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ import React from 'react';
import { FaSpinner } from 'react-icons/fa';

const LoadingIndicator: React.FC = () => {
return (
<div className="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50">
{/* <dotlottie-player
src="https://lottie.host/5a15fcda-33b9-4804-adb7-d0d45ddb5adf/6ViL1HZNqp.json"
background="transparent"
speed={1}
style={{ width: '200px', height: '200px' }}
loop
autoplay
></dotlottie-player> */}
{/* <FaSpinner className="animate-spin mr-2 text-[35px] text-blue-900 " /> */}
<div className="spinner border-t-[4px] border-b-[4px] border-blue-700 rounded-full w-8 h-8 animate-spin"></div>
</div>
return (<></>
// <div className="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50">
// {/* <dotlottie-player
// src="https://lottie.host/5a15fcda-33b9-4804-adb7-d0d45ddb5adf/6ViL1HZNqp.json"
// background="transparent"
// speed={1}
// style={{ width: '200px', height: '200px' }}
// loop
// autoplay
// ></dotlottie-player> */}
// {/* <FaSpinner className="animate-spin mr-2 text-[35px] text-blue-900 " /> */}
// {/* <div className="spinner border-t-[4px] border-b-[4px] border-blue-700 rounded-full w-8 h-8 animate-spin"></div> */}
// </div>
);
};

Expand Down
15 changes: 9 additions & 6 deletions src/Components/instructor/chat/instructorChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const InstructorChat: React.FC = () => {
return new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime();
});
const uniqueParticipants = new Set<string>();
const otherParticipants = sortedData.reduce((acc: any[], chat: any) => {
const otherParticipants = response?.payload?.data?.reduce((acc: any[], chat: any) => {
chat.participants.forEach((participant: any) => {
if (participant?._id !== data.data?._id && !uniqueParticipants.has(participant?._id)) {
uniqueParticipants.add(participant?._id);
Expand All @@ -233,15 +233,17 @@ const InstructorChat: React.FC = () => {
});
return acc;
}, []);

const sortedChats = otherParticipants.sort((a: any, b: any): number => {
return new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime();
});
setParticipants(sortedChats);
setLoading(false)
}
};



useEffect(() => {
if (socket && currentChat) {
const handleMessageReceive = (message: any) => {
Expand Down Expand Up @@ -280,7 +282,7 @@ const InstructorChat: React.FC = () => {
}
}, [socket, currentChat]);

const onSendMessage = async (message: string, contentType?: string) => {
const onSendMessage =(message: string, contentType?: string) => {
console.log('the real sender', data.data)
if (roomId && currentChat && data?.data?._id) {
const newMessage = {
Expand All @@ -290,12 +292,13 @@ const InstructorChat: React.FC = () => {
roomId,
contentType: contentType
};
console.log('this os send message')
socket?.emit("send-message", newMessage);
await dispatch(createMessageAction(newMessage));
// dispatch(createMessageAction(newMessage));
}
};


console.log('participants ',participants )

return (
<div className="flex h-screen overflow-y-hidden dark:bg-base-300">
Expand Down
8 changes: 4 additions & 4 deletions src/Components/instructor/students/myStudent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ const MyStudents: React.FC = () => {
try {
setLoading(true);
const studentsData = await dispatch(getMyStudentAction({ page, limit:limitPage,instructorId:data?.data?._id }));
console.log('data student',studentsData.payload.data)
if (getMyStudentAction.fulfilled.match(studentsData)) {
setStudents(studentsData.payload.data.students.reverse());
setTotalPages(Math.ceil(studentsData.payload.data.totalItems/limitPage));
console.log('data student',studentsData?.payload?.data)
if (getMyStudentAction?.fulfilled.match(studentsData)) {
setStudents(studentsData?.payload?.data?.students?.reverse());
setTotalPages(Math.ceil(studentsData?.payload?.data?.totalItems/limitPage));
} else {
setError('Failed to fetch students');
}
Expand Down
1 change: 1 addition & 0 deletions src/Components/user/course/course.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const CourseCard: React.FC<IframeHTMLAttributes<HTMLIFrameElement>> = () => {
}, 3000)



}


Expand Down
Loading

0 comments on commit 2d27e1b

Please sign in to comment.