fix: files not loading when creating a new project
This commit is contained in:
parent
2da60ff4e4
commit
1502047bf2
@ -49,10 +49,8 @@ export default function Dashboard({
|
|||||||
const q = searchParams.get("q")
|
const q = searchParams.get("q")
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => { // update the dashboard to show a new project
|
||||||
if (!sandboxes) {
|
|
||||||
router.refresh()
|
router.refresh()
|
||||||
}
|
|
||||||
}, [sandboxes])
|
}, [sandboxes])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -45,9 +45,13 @@ export default function CodeEditor({
|
|||||||
const { socket, setUserAndSandboxId } = useSocket();
|
const { socket, setUserAndSandboxId } = useSocket();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Check if socket is null, and initialize it by setting userId and sandboxId
|
// Ensure userData.id and sandboxData.id are available before attempting to connect
|
||||||
if (!socket && userData.id && sandboxData.id) {
|
if (userData.id && sandboxData.id) {
|
||||||
setUserAndSandboxId(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]);
|
}, [socket, userData.id, sandboxData.id, setUserAndSandboxId]);
|
||||||
|
|
||||||
@ -477,8 +481,7 @@ export default function CodeEditor({
|
|||||||
socket?.off("disableAccess", onDisableAccess)
|
socket?.off("disableAccess", onDisableAccess)
|
||||||
socket?.off("previewURL", loadPreviewURL)
|
socket?.off("previewURL", loadPreviewURL)
|
||||||
}
|
}
|
||||||
// }, []);
|
}, [socket, terminals, setTerminals, setFiles, toast, setDisableAccess, isOwner, loadPreviewURL]);
|
||||||
}, [terminals])
|
|
||||||
|
|
||||||
// Helper functions for tabs:
|
// Helper functions for tabs:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user