This pull request aims to improve the clarity, modularity, and structure of the socket event handling and chat-related components. It introduces new controllers, moves socket events into dedicated modules, and restructures the component files for better organization. Additionally, it integrates a centralized chat context for managing chat-related data using the useContext hook.
Changes
Socket Event Handling:
Integrated jwt verification and renamed configureSocket parameter from server to io for clarity in socketIo.js.
Implemented handleErrorEvents helper function in errorController.js.
Moved socket events message friend, message room, and chat activity to handleMessages in messageController.js.
Moved socket events joinRoom and leaveRoom to handleRoomEvents in roomController.js.
Integrated socket handlers handleMessages, handleRoomEvents, and handleErrorEvents into manageSocketEvents in socketController.js.
Connected manageSocketEvents with ioServer in server.js for centralized socket event management.
Component Restructuring:
Moved ClassQuizList.jsx, Newsfeed.jsx, QuizForm.jsx, and UserQuizList.jsx to the quizzes repository under the components directory.
Moved Classroom.jsx to the classroom repository under the components directory.
Moved Chat.jsx to the chat repository under the components directory.
Updated import paths to match the new file structure in Dashboard.jsx and Quizzes.jsx components.
Development Environment:
Ran npm install --save-dev @babel/plugin-proposal-private-property-in-object to ensure support for transpiling private properties across different environments and browsers.
Chat Context Implementation:
Created chatContext.js to manage chat messages, user classrooms, chat selection, and activity notifications, providing a centralized context for child components.
Moved chat utility functions and rendering logic to ChatDisplay.jsx for focused display management.
Moved chat control utility functions and rendering logic to ChatList.jsx for managing chat interactions.
Integrated ChatProvider, ChatDisplay, and ChatList into Chat.jsx for a more modular and organized chat component structure.
Summary
This pull request aims to improve the clarity, modularity, and structure of the socket event handling and chat-related components. It introduces new controllers, moves socket events into dedicated modules, and restructures the component files for better organization. Additionally, it integrates a centralized chat context for managing chat-related data using the
useContext
hook.Changes
Socket Event Handling:
jwt
verification and renamedconfigureSocket
parameter fromserver
toio
for clarity insocketIo.js
.handleErrorEvents
helper function inerrorController.js
.message friend
,message room
, andchat activity
tohandleMessages
inmessageController.js
.joinRoom
andleaveRoom
tohandleRoomEvents
inroomController.js
.handleMessages
,handleRoomEvents
, andhandleErrorEvents
intomanageSocketEvents
insocketController.js
.manageSocketEvents
withioServer
inserver.js
for centralized socket event management.Component Restructuring:
ClassQuizList.jsx
,Newsfeed.jsx
,QuizForm.jsx
, andUserQuizList.jsx
to thequizzes
repository under thecomponents
directory.Classroom.jsx
to theclassroom
repository under thecomponents
directory.Chat.jsx
to thechat
repository under thecomponents
directory.Dashboard.jsx
andQuizzes.jsx
components.Development Environment:
npm install --save-dev @babel/plugin-proposal-private-property-in-object
to ensure support for transpiling private properties across different environments and browsers.Chat Context Implementation:
chatContext.js
to manage chat messages, user classrooms, chat selection, and activity notifications, providing a centralized context for child components.ChatDisplay.jsx
for focused display management.ChatList.jsx
for managing chat interactions.ChatProvider
,ChatDisplay
, andChatList
intoChat.jsx
for a more modular and organized chat component structure.