Compare commits

...

3 Commits

Author SHA1 Message Date
Akhileshrangani4
6be2c02506 fix: socket connection 2024-09-01 22:04:56 -04:00
Akhileshrangani4
1d92b6ea6f chore: removed logs, added comments 2024-09-01 20:06:11 -04:00
Akhileshrangani4
f683ff6480 fix: files not loading when creating a new project
This push contains console logs at various places where the server is emitting the event and the client is receiving the event. Please remove those before merging with production.
2024-08-31 20:31:20 -04:00
2 changed files with 11 additions and 10 deletions

View File

@ -49,10 +49,8 @@ export default function Dashboard({
const q = searchParams.get("q")
const router = useRouter()
useEffect(() => {
if (!sandboxes) {
router.refresh()
}
useEffect(() => { // update the dashboard to show a new project
router.refresh()
}, [sandboxes])
return (

View File

@ -45,9 +45,13 @@ export default function CodeEditor({
const { socket, setUserAndSandboxId } = useSocket();
useEffect(() => {
// Check if socket is null, and initialize it by setting userId and sandboxId
if (!socket && userData.id && sandboxData.id) {
setUserAndSandboxId(userData.id, sandboxData.id);
// Ensure userData.id and sandboxData.id are available before attempting to connect
if (userData.id && sandboxData.id) {
// Check if the socket is not initialized or not connected
if (!socket || (socket && !socket.connected)) {
// Initialize socket connection
setUserAndSandboxId(userData.id, sandboxData.id);
}
}
}, [socket, userData.id, sandboxData.id, setUserAndSandboxId]);
@ -427,7 +431,7 @@ export default function CodeEditor({
return () => {
socket?.disconnect()
}
}, [])
}, [socket])
// Socket event listener effect
useEffect(() => {
@ -477,8 +481,7 @@ export default function CodeEditor({
socket?.off("disableAccess", onDisableAccess)
socket?.off("previewURL", loadPreviewURL)
}
// }, []);
}, [terminals])
}, [socket, terminals, setTerminals, setFiles, toast, setDisableAccess, isOwner, loadPreviewURL]);
// Helper functions for tabs: