Compare commits

..

9 Commits

Author SHA1 Message Date
James Murdza
9fd1f81654 fix: remove useCallback, fixing null socket issue when reading files 2024-09-01 21:53:59 -07:00
James Murdza
665e36603f Merge branch 'refs/heads/fix-files-loading' 2024-09-01 19:31:33 -07:00
Akhileshrangani4
0679f99bb7 fix: socket connection 2024-09-01 19:31:25 -07:00
James Murdza
2065814aaa Merge branch 'refs/heads/fix-files-loading'
# Conflicts:
#	frontend/components/editor/navbar/run.tsx
2024-09-01 18:31:15 -07:00
Akhileshrangani4
1502047bf2 fix: files not loading when creating a new project 2024-09-01 18:25:25 -07:00
Akhileshrangani4
bbd47db467 chore: start to dev 2024-08-28 19:45:35 -07:00
Akhilesh Rangani
a15c1f15f5 fix: types mismatch 2024-08-19 18:17:50 -07:00
Akhilesh Rangani
f1a65106b0 feat: different run commands based on file types 2024-08-19 17:45:47 -07:00
James Murdza
5726cecb22 fix: remove undefined type 2024-08-18 12:37:08 -07:00
4 changed files with 11 additions and 21 deletions

View File

@@ -143,8 +143,6 @@ io.on("connection", async (socket) => {
isOwner: boolean;
};
console.log("user:",data)
if (data.isOwner) {
isOwnerConnected = true;
connections[data.sandboxId] = (connections[data.sandboxId] ?? 0) + 1;
@@ -185,7 +183,6 @@ io.on("connection", async (socket) => {
fixPermissions();
socket.emit("loaded", sandboxFiles.files);
console.log("files got", sandboxFiles.files)
socket.on("getFile", (fileId: string, callback) => {
console.log(fileId);

View File

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

View File

@@ -45,13 +45,11 @@ export default function CodeEditor({
const { socket, setUserAndSandboxId } = useSocket();
useEffect(() => {
console.log('Effect triggered:', { socket, userData, sandboxData });
// 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
console.log('Initializing socket...');
setUserAndSandboxId(userData.id, sandboxData.id);
}
}
@@ -433,7 +431,7 @@ export default function CodeEditor({
return () => {
socket?.disconnect()
}
}, [])
}, [socket])
// Socket event listener effect
useEffect(() => {
@@ -445,7 +443,6 @@ export default function CodeEditor({
const onLoadedEvent = (files: (TFolder | TFile)[]) => {
setFiles(files)
console.log("loaded", files)
}
const onError = (message: string) => {
@@ -484,7 +481,6 @@ export default function CodeEditor({
socket?.off("disableAccess", onDisableAccess)
socket?.off("previewURL", loadPreviewURL)
}
// }, []);
}, [socket, terminals, setTerminals, setFiles, toast, setDisableAccess, isOwner, loadPreviewURL]);
// Helper functions for tabs:
@@ -495,14 +491,13 @@ export default function CodeEditor({
const fileCache = useRef(new Map());
// Debounced function to get file content
const debouncedGetFile = useCallback(
debounce((tabId, callback) => {
socket?.emit('getFile', tabId, callback);
}, 300), // 300ms debounce delay, adjust as needed
[]
);
const debouncedGetFile =
(tabId: any, callback: any) => {
socket?.emit('getFile', tabId, callback);
} // 300ms debounce delay, adjust as needed
const selectFile = (tab: TTab) => {
const selectFile = useCallback((tab: TTab) => {
if (tab.id === activeFileId) return;
setGenerate((prev) => ({ ...prev, show: false }));
@@ -527,7 +522,7 @@ export default function CodeEditor({
setEditorLanguage(processFileType(tab.name));
setActiveFileId(tab.id);
}, [activeFileId, tabs, debouncedGetFile]);
};
// Close tab and remove from tabs
const closeTab = (id: string) => {

View File

@@ -44,7 +44,7 @@ export default function RunButtonModal({
"pip install -r requirements.txt && streamlit run main.py --server.runOnSave true"
);
} else {
createNewTerminal("yarn install && yarn dev");
createNewTerminal("yarn install && yarn dev");
}
} else {
toast.error("You reached the maximum # of terminals.");