Add support for the via query param
This commit is contained in:
parent
442086f31b
commit
26dad81e06
2 changed files with 17 additions and 9 deletions
|
@ -47,8 +47,13 @@ async function initClient(clientOptions, guest) {
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchGroupCall(client, roomIdOrAlias, timeout = 5000) {
|
export async function fetchGroupCall(
|
||||||
const { roomId } = await client.joinRoom(roomIdOrAlias);
|
client,
|
||||||
|
roomIdOrAlias,
|
||||||
|
viaServers = undefined,
|
||||||
|
timeout = 5000
|
||||||
|
) {
|
||||||
|
const { roomId } = await client.joinRoom(roomIdOrAlias, { viaServers });
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let timeoutId;
|
let timeoutId;
|
||||||
|
|
17
src/Room.jsx
17
src/Room.jsx
|
@ -48,7 +48,7 @@ const canScreenshare = "getDisplayMedia" in navigator.mediaDevices;
|
||||||
// For now we can disable screensharing in Safari.
|
// For now we can disable screensharing in Safari.
|
||||||
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
||||||
|
|
||||||
function useLoadGroupCall(client, roomId) {
|
function useLoadGroupCall(client, roomId, viaServers) {
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
loading: true,
|
loading: true,
|
||||||
error: undefined,
|
error: undefined,
|
||||||
|
@ -57,7 +57,7 @@ function useLoadGroupCall(client, roomId) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setState({ loading: true });
|
setState({ loading: true });
|
||||||
fetchGroupCall(client, roomId, 30000)
|
fetchGroupCall(client, roomId, viaServers, 30000)
|
||||||
.then((groupCall) => setState({ loading: false, groupCall }))
|
.then((groupCall) => setState({ loading: false, groupCall }))
|
||||||
.catch((error) => setState({ loading: false, error }));
|
.catch((error) => setState({ loading: false, error }));
|
||||||
}, [roomId]);
|
}, [roomId]);
|
||||||
|
@ -68,11 +68,15 @@ function useLoadGroupCall(client, roomId) {
|
||||||
export function Room({ client }) {
|
export function Room({ client }) {
|
||||||
const { roomId: maybeRoomId } = useParams();
|
const { roomId: maybeRoomId } = useParams();
|
||||||
const { hash, search } = useLocation();
|
const { hash, search } = useLocation();
|
||||||
|
const [simpleGrid, viaServers] = useMemo(() => {
|
||||||
|
const params = new URLSearchParams(search);
|
||||||
|
return [params.has("simple"), params.getAll("via")];
|
||||||
|
}, [search]);
|
||||||
const roomId = maybeRoomId || hash;
|
const roomId = maybeRoomId || hash;
|
||||||
const { loading, error, groupCall } = useLoadGroupCall(client, roomId);
|
const { loading, error, groupCall } = useLoadGroupCall(
|
||||||
const simpleGrid = useMemo(
|
client,
|
||||||
() => new URLSearchParams(search).has("simple"),
|
roomId,
|
||||||
[search]
|
viaServers
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -138,7 +142,6 @@ export function GroupCallView({ client, groupCall, simpleGrid }) {
|
||||||
Sentry.captureException(error);
|
Sentry.captureException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (groupCall) {
|
if (groupCall) {
|
||||||
groupCall.on("hangup", onHangup);
|
groupCall.on("hangup", onHangup);
|
||||||
groupCall.on("error", onError);
|
groupCall.on("error", onError);
|
||||||
|
|
Loading…
Add table
Reference in a new issue