refactor: allow for full trystero configuration

This commit is contained in:
Jeremy Kahn 2022-08-20 17:14:50 -05:00
parent b8f8bb5bfd
commit d4bc49f096
2 changed files with 10 additions and 11 deletions

View File

@ -28,10 +28,12 @@ export function Room({
[]
)
const peerRoom = usePeerRoom({
appId,
roomId,
})
const peerRoom = usePeerRoom(
{
appId,
},
roomId
)
const [sendMessage, receiveMessage] = usePeerRoomAction<UnsentMessage>(
peerRoom,

View File

@ -1,14 +1,11 @@
import { useEffect, useState } from 'react'
import { RoomConfig } from 'trystero'
import { getPeerRoom } from 'services/PeerRoom'
interface UsePeerRoomProps {
appId: string
roomId: string
}
export function usePeerRoom({ appId, roomId }: UsePeerRoomProps) {
const [peerRoom, setPeerRoom] = useState(getPeerRoom({ appId }, roomId))
export function usePeerRoom(roomConfig: RoomConfig, roomId: string) {
const { appId } = roomConfig
const [peerRoom, setPeerRoom] = useState(getPeerRoom(roomConfig, roomId))
useEffect(() => {
setPeerRoom(getPeerRoom({ appId }, roomId))