From 94ca5b2c9f100f30be870722ed2346e3a904c3d6 Mon Sep 17 00:00:00 2001 From: Akhileshrangani4 Date: Sun, 17 Nov 2024 17:52:39 -0500 Subject: [PATCH] fix: comment out live collaboration features --- frontend/app/(app)/code/[id]/page.tsx | 6 +- frontend/app/api/lb-auth/route.ts | 102 ++++++------ frontend/components/dashboard/index.tsx | 4 +- frontend/components/editor/index.tsx | 174 ++++++++++---------- frontend/components/editor/navbar/index.tsx | 8 +- frontend/components/landing/index.tsx | 7 +- 6 files changed, 155 insertions(+), 146 deletions(-) diff --git a/frontend/app/(app)/code/[id]/page.tsx b/frontend/app/(app)/code/[id]/page.tsx index 27bf89e..bf5f6ff 100644 --- a/frontend/app/(app)/code/[id]/page.tsx +++ b/frontend/app/(app)/code/[id]/page.tsx @@ -1,4 +1,4 @@ -import { Room } from "@/components/editor/live/room" +// import { Room } from "@/components/editor/live/room" import Loading from "@/components/editor/loading" import Navbar from "@/components/editor/navbar" import { TerminalProvider } from "@/context/TerminalContext" @@ -89,7 +89,7 @@ export default async function CodePage({ params }: { params: { id: string } }) { return ( <>
- + {/* */}
- + {/* */} ) diff --git a/frontend/app/api/lb-auth/route.ts b/frontend/app/api/lb-auth/route.ts index 409ea87..d415055 100644 --- a/frontend/app/api/lb-auth/route.ts +++ b/frontend/app/api/lb-auth/route.ts @@ -1,57 +1,61 @@ -import { colors } from "@/lib/colors" -import { User } from "@/lib/types" +// import { colors } from "@/lib/colors" +// import { User } from "@/lib/types" import { currentUser } from "@clerk/nextjs" -import { Liveblocks } from "@liveblocks/node" +// import { Liveblocks } from "@liveblocks/node" import { NextRequest } from "next/server" -const API_KEY = process.env.LIVEBLOCKS_SECRET_KEY! +// const API_KEY = process.env.LIVEBLOCKS_SECRET_KEY! -const liveblocks = new Liveblocks({ - secret: API_KEY!, -}) +// const liveblocks = new Liveblocks({ +// secret: API_KEY!, +// }) export async function POST(request: NextRequest) { - const clerkUser = await currentUser() + // Temporarily return unauthorized while Liveblocks is disabled + return new Response("Liveblocks collaboration temporarily disabled", { status: 503 }) - if (!clerkUser) { - return new Response("Unauthorized", { status: 401 }) - } - - const res = await fetch( - `${process.env.NEXT_PUBLIC_DATABASE_WORKER_URL}/api/user?id=${clerkUser.id}`, - { - headers: { - Authorization: `${process.env.NEXT_PUBLIC_WORKERS_KEY}`, - }, - } - ) - const user = (await res.json()) as User - - const colorNames = Object.keys(colors) - const randomColor = colorNames[ - Math.floor(Math.random() * colorNames.length) - ] as keyof typeof colors - const code = colors[randomColor] - - // Create a session for the current user - // userInfo is made available in Liveblocks presence hooks, e.g. useOthers - const session = liveblocks.prepareSession(user.id, { - userInfo: { - name: user.name, - email: user.email, - color: randomColor, - }, - }) - - // Give the user access to the room - user.sandbox.forEach((sandbox) => { - session.allow(`${sandbox.id}`, session.FULL_ACCESS) - }) - user.usersToSandboxes.forEach((userToSandbox) => { - session.allow(`${userToSandbox.sandboxId}`, session.FULL_ACCESS) - }) - - // Authorize the user and return the result - const { body, status } = await session.authorize() - return new Response(body, { status }) + // Original implementation commented out: + // const clerkUser = await currentUser() + // + // if (!clerkUser) { + // return new Response("Unauthorized", { status: 401 }) + // } + // + // const res = await fetch( + // `${process.env.NEXT_PUBLIC_DATABASE_WORKER_URL}/api/user?id=${clerkUser.id}`, + // { + // headers: { + // Authorization: `${process.env.NEXT_PUBLIC_WORKERS_KEY}`, + // }, + // } + // ) + // const user = (await res.json()) as User + // + // const colorNames = Object.keys(colors) + // const randomColor = colorNames[ + // Math.floor(Math.random() * colorNames.length) + // ] as keyof typeof colors + // const code = colors[randomColor] + // + // // Create a session for the current user + // // userInfo is made available in Liveblocks presence hooks, e.g. useOthers + // const session = liveblocks.prepareSession(user.id, { + // userInfo: { + // name: user.name, + // email: user.email, + // color: randomColor, + // }, + // }) + // + // // Give the user access to the room + // user.sandbox.forEach((sandbox) => { + // session.allow(`${sandbox.id}`, session.FULL_ACCESS) + // }) + // user.usersToSandboxes.forEach((userToSandbox) => { + // session.allow(`${userToSandbox.sandboxId}`, session.FULL_ACCESS) + // }) + // + // // Authorize the user and return the result + // const { body, status } = await session.authorize() + // return new Response(body, { status }) } diff --git a/frontend/components/dashboard/index.tsx b/frontend/components/dashboard/index.tsx index 8f693be..6bcb90f 100644 --- a/frontend/components/dashboard/index.tsx +++ b/frontend/components/dashboard/index.tsx @@ -78,14 +78,14 @@ export default function Dashboard({ My Projects - + */} {/* + */} ) : null} diff --git a/frontend/components/landing/index.tsx b/frontend/components/landing/index.tsx index af18866..d3c67e8 100644 --- a/frontend/components/landing/index.tsx +++ b/frontend/components/landing/index.tsx @@ -45,9 +45,14 @@ export default function Landing() {

A Collaborative + AI-Powered Code Environment

-

+ {/*

Sandbox is an open-source cloud-based code editing environment with custom AI code autocompletion and real-time collaboration. +

*/} +

+ A cloud-based code editor featuring real-time collaboration, + intelligent code autocompletion, and an AI assistant to help you code + faster and smarter.