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({
|
const peerRoom = usePeerRoom(
|
||||||
appId,
|
{
|
||||||
roomId,
|
appId,
|
||||||
})
|
},
|
||||||
|
roomId
|
||||||
|
)
|
||||||
|
|
||||||
const [sendMessage, receiveMessage] = usePeerRoomAction<UnsentMessage>(
|
const [sendMessage, receiveMessage] = usePeerRoomAction<UnsentMessage>(
|
||||||
peerRoom,
|
peerRoom,
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
|
import { RoomConfig } from 'trystero'
|
||||||
|
|
||||||
import { getPeerRoom } from 'services/PeerRoom'
|
import { getPeerRoom } from 'services/PeerRoom'
|
||||||
|
|
||||||
interface UsePeerRoomProps {
|
export function usePeerRoom(roomConfig: RoomConfig, roomId: string) {
|
||||||
appId: string
|
const { appId } = roomConfig
|
||||||
roomId: string
|
const [peerRoom, setPeerRoom] = useState(getPeerRoom(roomConfig, roomId))
|
||||||
}
|
|
||||||
|
|
||||||
export function usePeerRoom({ appId, roomId }: UsePeerRoomProps) {
|
|
||||||
const [peerRoom, setPeerRoom] = useState(getPeerRoom({ appId }, roomId))
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setPeerRoom(getPeerRoom({ appId }, roomId))
|
setPeerRoom(getPeerRoom({ appId }, roomId))
|
||||||
|
Loading…
Reference in New Issue
Block a user