This pull request introduces significant improvements to the chat and classroom functionality by refactoring socket event handling, integrating new controller functions, and updating the service and API layers. The goal is to enhance modularity, clarity, and efficiency in managing classroom chats.
Changes
Removed Redundant Socket Functionality:
Cleaned up unnecessary socket logic from controller functions in chatController.js.
Implemented getClassrooms Controller Function:
Added a new function in chatController.js to handle the retrieval of classrooms.
Separated Chat Functionality into Socket Events:
Moved chat operations like joinRoom and messageRoom from controller functions to socketController.js to decouple chat logic from other operations.
Updated API Endpoints:
Integrated the new controller functions into their respective API endpoints in chatRoutes.js.
Store Integration:
Added chatReducer to the store configuration in store.js to manage chat-related state.
Service Function Enhancements:
Implemented and exported service functions getClassrooms, getClassroomMessages, and getUserMessages in chatService.js.
Renamed sendMessage to sendFriendMessage to clarify its purpose.
Adjusted API endpoint parameters from classroomId to classroomName in joinClassroom.
Renamed getMessages to getUserMessages for consistency.
Route Adjustments:
Commented out conflicting routes that interfered with classroom/leave, preventing user access issues.
Notes:
The joinClassroom functionality has not been completely solved. I am currently working on identifying the specific route causing the conflict and will update the issue accordingly.
Summary
This pull request introduces significant improvements to the chat and classroom functionality by refactoring socket event handling, integrating new controller functions, and updating the service and API layers. The goal is to enhance modularity, clarity, and efficiency in managing classroom chats.
Changes
Removed Redundant Socket Functionality:
chatController.js
.Implemented
getClassrooms
Controller Function:chatController.js
to handle the retrieval of classrooms.Separated Chat Functionality into Socket Events:
joinRoom
andmessageRoom
from controller functions tosocketController.js
to decouple chat logic from other operations.Updated API Endpoints:
chatRoutes.js
.Store Integration:
chatReducer
to the store configuration instore.js
to manage chat-related state.Service Function Enhancements:
getClassrooms
,getClassroomMessages
, andgetUserMessages
inchatService.js
.sendMessage
tosendFriendMessage
to clarify its purpose.classroomId
toclassroomName
injoinClassroom
.getMessages
togetUserMessages
for consistency.Route Adjustments:
classroom/leave
, preventing user access issues.Notes:
joinClassroom
functionality has not been completely solved. I am currently working on identifying the specific route causing the conflict and will update the issue accordingly.