refactor: allow for full trystero configuration
This commit is contained in:
parent
b8f8bb5bfd
commit
d4bc49f096
@ -28,10 +28,12 @@ export function Room({
|
||||
[]
|
||||
)
|
||||
|
||||
const peerRoom = usePeerRoom({
|
||||
appId,
|
||||
roomId,
|
||||
})
|
||||
const peerRoom = usePeerRoom(
|
||||
{
|
||||
appId,
|
||||
},
|
||||
roomId
|
||||
)
|
||||
|
||||
const [sendMessage, receiveMessage] = usePeerRoomAction<UnsentMessage>(
|
||||
peerRoom,
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user