2021-09-04 12:18:44 +00:00
|
|
|
import * as React from 'react'
|
|
|
|
import type { GetServerSideProps } from 'next'
|
2021-12-22 00:14:38 +00:00
|
|
|
import { getSession } from 'next-auth/react'
|
2021-09-04 12:18:44 +00:00
|
|
|
import dynamic from 'next/dynamic'
|
2022-07-12 10:12:00 +00:00
|
|
|
|
|
|
|
const IFrameWarning = dynamic(() => import('components/IFrameWarning'), {
|
|
|
|
ssr: false,
|
|
|
|
}) as any
|
|
|
|
|
2022-05-14 13:15:55 +00:00
|
|
|
const MultiplayerEditor = dynamic(() => import('components/MultiplayerEditor'), {
|
|
|
|
ssr: false,
|
|
|
|
}) as any
|
2021-09-04 12:18:44 +00:00
|
|
|
|
|
|
|
interface RoomProps {
|
|
|
|
id: string
|
2021-11-16 16:01:29 +00:00
|
|
|
isSponsor: boolean
|
|
|
|
isUser: boolean
|
2021-09-04 12:18:44 +00:00
|
|
|
}
|
|
|
|
|
2022-05-14 13:15:55 +00:00
|
|
|
export default function Room({ id, isUser, isSponsor }: RoomProps) {
|
2022-07-08 20:31:32 +00:00
|
|
|
if (typeof window !== 'undefined' && window.self !== window.top) {
|
2022-07-08 20:25:08 +00:00
|
|
|
return <IFrameWarning url={`https://tldraw.com/r/${id}`} />
|
|
|
|
}
|
|
|
|
|
2021-11-16 16:01:29 +00:00
|
|
|
return <MultiplayerEditor isUser={isUser} isSponsor={isSponsor} roomId={id} />
|
2021-09-04 12:18:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const getServerSideProps: GetServerSideProps = async (context) => {
|
|
|
|
const session = await getSession(context)
|
|
|
|
const id = context.query.id?.toString()
|
2022-05-18 15:59:30 +00:00
|
|
|
|
2021-09-04 12:18:44 +00:00
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
id,
|
2021-11-19 14:33:15 +00:00
|
|
|
isUser: session?.user ? true : false,
|
2022-01-12 13:36:19 +00:00
|
|
|
isSponsor: session?.isSponsor ?? false,
|
2021-09-04 12:18:44 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|