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 router = useRouter()
|
||||
|
||||
useEffect(() => {
|
||||
if (!sandboxes) {
|
||||
useEffect(() => { // update the dashboard to show a new project
|
||||
router.refresh()
|
||||
}
|
||||
}, [sandboxes])
|
||||
|
||||
return (
|
||||
|
@ -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]);
|
||||
|
||||
@ -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:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user