Skip to content

Commit

Permalink
Disable SSR when iniatializing collaboration provider
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianUribe6 committed Mar 2, 2024
1 parent 31058ea commit 7af2717
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
23 changes: 13 additions & 10 deletions apps/front-end/src/app/[notebookId]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { getNotebookById } from "@/actions/document";
import { getToken } from "@/actions/token";
import { getSession } from "@/config/auth-options";
import { StartCollaboration } from "@/lib/collaboration";
import { notFound } from "next/navigation";
import { PropsWithChildren } from "react";
import Header from "../Header";
import SideNavigation from "../SideNavigation";
import { StartCollaboration } from "@/lib/collaboration";
import NoSSR from "@/components/NoSSR";

type LayoutProps = PropsWithChildren<{
params: {
Expand All @@ -30,15 +31,17 @@ async function Layout({ children, params }: LayoutProps) {
<div>
<Header />
{session?.user && (
<StartCollaboration
user={session.user}
notebookName={notebook.document.documentName}
initialToken={token}
onTokenRefresh={async () => {
"use server";
return getToken([]);
}}
/>
<NoSSR>
<StartCollaboration
user={session.user}
notebookName={notebook.document.documentName}
initialToken={token}
onTokenRefresh={async () => {
"use server";
return getToken([]);
}}
/>
</NoSSR>
)}
{children}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ export function useAwareness() {
const [awareness, setAwareness] = useState<AwarenessState[]>([]);
useEffect(() => {
const onAwarenessChange = ({ states }: { states: AwarenessState[] }) => {
console.log(states);
setAwareness(states);
};
provider.on("awarenessUpdate", onAwarenessChange);
Expand Down

0 comments on commit 7af2717

Please sign in to comment.