element-call/src/room/GroupCallLoader.jsx

43 lines
1 KiB
React
Raw Normal View History

2022-01-05 23:35:12 +00:00
import React from "react";
2022-01-06 00:51:24 +00:00
import { useLoadGroupCall } from "./useLoadGroupCall";
2022-01-05 23:35:12 +00:00
import { ErrorView, FullScreenView } from "../FullScreenView";
2022-02-02 23:02:40 +00:00
import { usePageTitle } from "../usePageTitle";
2022-02-14 21:53:19 +00:00
import { isLocalRoomId } from "../matrix-utils";
import { RoomNotFoundView } from "./RoomNotFoundView";
2022-01-05 23:35:12 +00:00
export function GroupCallLoader({ client, roomId, viaServers, children }) {
const { loading, error, groupCall, reload } = useLoadGroupCall(
2022-01-05 23:35:12 +00:00
client,
roomId,
viaServers
);
2022-02-02 23:02:40 +00:00
usePageTitle(groupCall ? groupCall.room.name : "Loading...");
2022-01-05 23:35:12 +00:00
if (loading) {
return (
<FullScreenView>
<h1>Loading room...</h1>
</FullScreenView>
);
}
2022-02-15 23:00:06 +00:00
if (
error &&
(error.errcode === "M_NOT_FOUND" ||
(error.message &&
error.message.indexOf("Failed to fetch alias") !== -1)) &&
isLocalRoomId(roomId)
) {
return (
<RoomNotFoundView client={client} roomId={roomId} onReload={reload} />
);
2022-02-14 21:53:19 +00:00
}
2022-01-05 23:35:12 +00:00
if (error) {
return <ErrorView error={error} />;
}
return children(groupCall);
}