Set room more reliably

This commit is contained in:
Robert Long 2021-08-04 17:04:24 -07:00
parent c237c53484
commit 65c65dbb30

View file

@ -144,8 +144,6 @@ export function useVideoRoom(manager, roomId, timeout = 5000) {
error: undefined,
}));
manager.setRoom(roomId);
manager.client.joinRoom(roomId).catch((err) => {
setState((prevState) => ({ ...prevState, loading: false, error: err }));
});
@ -153,6 +151,7 @@ export function useVideoRoom(manager, roomId, timeout = 5000) {
let initialRoom = manager.client.getRoom(roomId);
if (initialRoom) {
manager.setRoom(roomId);
setState((prevState) => ({
...prevState,
loading: false,
@ -168,6 +167,7 @@ export function useVideoRoom(manager, roomId, timeout = 5000) {
if (room && room.roomId === roomId) {
clearTimeout(timeoutId);
manager.client.removeListener("Room", roomCallback);
manager.setRoom(roomId);
setState((prevState) => ({
...prevState,
loading: false,