diff --git a/frontend/app/(app)/code/[id]/page.tsx b/frontend/app/(app)/code/[id]/page.tsx index 7a1e236..f8b58be 100644 --- a/frontend/app/(app)/code/[id]/page.tsx +++ b/frontend/app/(app)/code/[id]/page.tsx @@ -5,6 +5,8 @@ import { currentUser } from "@clerk/nextjs"; import { notFound, redirect } from "next/navigation"; import Editor from "@/components/editor"; +export const revalidate = 0; + const getUserData = async (id: string) => { const userRes = await fetch( `https://database.ishaan1013.workers.dev/api/user?id=${id}` diff --git a/frontend/components/editor/editor.tsx b/frontend/components/editor/editor.tsx index ce7c6da..2ae3a71 100644 --- a/frontend/components/editor/editor.tsx +++ b/frontend/components/editor/editor.tsx @@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from "react"; import monaco from "monaco-editor"; import Editor, { BeforeMount, OnMount } from "@monaco-editor/react"; -import { Socket, io } from "socket.io-client"; +import { io } from "socket.io-client"; import { toast } from "sonner"; import { useClerk } from "@clerk/nextjs"; @@ -40,8 +40,11 @@ export default function CodeEditor({ sandboxData: Sandbox; }) { const socket = io( - `ws://${sandboxData.id}.ws.ishaand.com?userId=${userData.id}&sandboxId=${sandboxData.id}` - // `http://localhost:4000?userId=${userData.id}&sandboxId=${sandboxData.id}` + // `ws://${sandboxData.id}.ws.ishaand.com?userId=${userData.id}&sandboxId=${sandboxData.id}` + `http://localhost:4000?userId=${userData.id}&sandboxId=${sandboxData.id}`, + { + timeout: 2000, + } ); const [isAwaitingConnection, setIsAwaitingConnection] = useState(true); @@ -695,6 +698,7 @@ export default function CodeEditor({ } }} options={{ + tabSize: 2, minimap: { enabled: false, }, diff --git a/frontend/lib/utils.ts b/frontend/lib/utils.ts index ecc6ced..d2259e0 100644 --- a/frontend/lib/utils.ts +++ b/frontend/lib/utils.ts @@ -2,6 +2,8 @@ import { type ClassValue, clsx } from "clsx"; // import { toast } from "sonner" import { twMerge } from "tailwind-merge"; import { Sandbox, TFile, TFolder } from "./types"; +import ecsClient from "./ecs"; +import { DescribeServicesCommand } from "@aws-sdk/client-ecs"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); @@ -91,3 +93,32 @@ export function addNew( // callback(false); // } // } + +// const checkServiceStatus = (serviceName: string) => { +// return new Promise((resolve, reject) => { + +// const command = new DescribeServicesCommand({ +// cluster: "arn:aws:ecs:us-east-1:767398085538:service/Sandbox/Sandbox", +// services: [serviceName] +// }) + +// const interval = setInterval(async () => { +// try { + +// const response = await ecsClient.send(command) + +// if (response.services && response.services.length > 0) { +// const service = response.services?.[0]; +// if (service.runningCount === service.desiredCount && service.deployments.length === 1 && service.deployments[0].rolloutState === 'COMPLETED') { +// clearInterval(interval); +// resolve(service); +// } +// } + +// } catch (error) { +// clearInterval(interval); +// reject(error); +// } +// }, 5000); // Check every 5 seconds +// }); +// };