mirror of
https://github.com/arkorty/Osborne.git
synced 2026-03-18 00:57:14 +00:00
user fixes
This commit is contained in:
@@ -208,6 +208,7 @@ const Room = () => {
|
||||
const socketRef = useRef<WebSocket | null>(null);
|
||||
const editorRef = useRef<CodeEditorRef>(null);
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const currentUserRef = useRef<User | null>(null);
|
||||
const [isClient, setIsClient] = useState(false);
|
||||
const [content, setContent] = useState("");
|
||||
const [status, setStatus] = useState("Disconnected");
|
||||
@@ -317,6 +318,10 @@ const Room = () => {
|
||||
contentRef.current = content;
|
||||
}, [content]);
|
||||
|
||||
useEffect(() => {
|
||||
currentUserRef.current = currentUser;
|
||||
}, [currentUser]);
|
||||
|
||||
useEffect(() => {
|
||||
setIsClient(true);
|
||||
|
||||
@@ -604,7 +609,19 @@ const Room = () => {
|
||||
|
||||
const pingInterval = setInterval(() => {
|
||||
if (socketRef.current?.readyState === WebSocket.OPEN) {
|
||||
socketRef.current.send(JSON.stringify({ type: "ping" }));
|
||||
socketRef.current.send(JSON.stringify({ type: "ping", code: roomCode }));
|
||||
|
||||
// Also send user activity update to keep status current
|
||||
if (currentUserRef.current) {
|
||||
const activityMessage: UserActivity = {
|
||||
type: "user-activity",
|
||||
code: roomCode,
|
||||
userId: currentUserRef.current.id,
|
||||
isTyping: false,
|
||||
currentLine: undefined
|
||||
};
|
||||
socketRef.current.send(JSON.stringify(activityMessage));
|
||||
}
|
||||
}
|
||||
}, 30000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user