tldraw/packages/www/pages/r/[id].tsx
Steve Ruiz 99730b4fe2
[feature] MVP multiplayer support (#135)
* Adds multiplayer support

* Update liveblocks.tsx

* Update liveblocks.tsx

* Create chaos.tsx

* Fix undo redo, add merge state

* Update multiplayer-editor.tsx

* Adds secret room

* Update chaos.tsx

* Moves shhh to shhhmp

* Fix accidentally deleting the editing shape

* Fix bug where a selected shape is deleted by another user.

* Remove relative path

* Tweak editor

* Remove chaos endpoint

* Adds error state for maximum connections, fixes selectedIds bug on new rooms
2021-10-09 00:05:24 +01:00

39 lines
896 B
TypeScript

import * as React from 'react'
import type { GetServerSideProps } from 'next'
import Head from 'next/head'
import { getSession } from 'next-auth/client'
import dynamic from 'next/dynamic'
const MultiplayerEditor = dynamic(() => import('components/multiplayer-editor'), { ssr: false })
interface RoomProps {
id: string
}
export default function Room({ id }: RoomProps): JSX.Element {
return (
<>
<Head>
<title>tldraw</title>
</Head>
<MultiplayerEditor id={id} />
</>
)
}
export const getServerSideProps: GetServerSideProps = async (context) => {
const session = await getSession(context)
if (!session?.user && process.env.NODE_ENV !== 'development') {
context.res.setHeader('Location', `/sponsorware`)
context.res.statusCode = 307
}
const id = context.query.id?.toString()
return {
props: {
id,
session,
},
}
}