MAJOR Fix: Resolved API Request Delays;
Feat: Added a dev test account to users for expedited login; Refactor: Improve socket connection handling and add logging for API request duration & update to ListRow key generation for improved uniqueness; Feat: Made it so streams with no set thumbnail use their category's thumbnail; Minor Fix: Corrections to db recommendation methods;
This commit is contained in:
@@ -23,8 +23,17 @@ const ChatPanel: React.FC<ChatPanelProps> = ({ streamId }) => {
|
||||
// Join chat room when component mounts
|
||||
useEffect(() => {
|
||||
if (socket && isConnected) {
|
||||
// Join chat room
|
||||
socket.emit("join", { stream_id: streamId });
|
||||
|
||||
// Handle beforeunload event
|
||||
const handleBeforeUnload = () => {
|
||||
socket.emit("leave", { stream_id: streamId });
|
||||
socket.disconnect();
|
||||
};
|
||||
|
||||
window.addEventListener("beforeunload", handleBeforeUnload);
|
||||
|
||||
// Load initial chat history
|
||||
fetch(`/api/chat/${streamId}`)
|
||||
.then((response) => {
|
||||
@@ -45,9 +54,11 @@ const ChatPanel: React.FC<ChatPanelProps> = ({ streamId }) => {
|
||||
setMessages((prev) => [...prev, data]);
|
||||
});
|
||||
|
||||
// Cleanup
|
||||
// Cleanup function
|
||||
return () => {
|
||||
window.removeEventListener("beforeunload", handleBeforeUnload);
|
||||
socket.emit("leave", { stream_id: streamId });
|
||||
socket.disconnect();
|
||||
socket.off("new_message");
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user