2022-05-04 17:09:48 +01:00
|
|
|
/*
|
|
|
|
Copyright 2022 Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-08-02 00:46:16 +02:00
|
|
|
import React, { ReactNode } from "react";
|
2022-08-12 16:46:53 -04:00
|
|
|
import { MatrixClient } from "matrix-js-sdk/src/client";
|
|
|
|
import { GroupCall } from "matrix-js-sdk/src/webrtc/groupCall";
|
2022-10-10 09:19:10 -04:00
|
|
|
import { useTranslation } from "react-i18next";
|
2022-08-02 00:46:16 +02:00
|
|
|
|
2022-01-05 16:51:24 -08:00
|
|
|
import { useLoadGroupCall } from "./useLoadGroupCall";
|
2022-01-05 15:35:12 -08:00
|
|
|
import { ErrorView, FullScreenView } from "../FullScreenView";
|
2022-02-02 15:02:40 -08:00
|
|
|
import { usePageTitle } from "../usePageTitle";
|
2022-01-05 15:35:12 -08:00
|
|
|
|
2022-08-02 00:46:16 +02:00
|
|
|
interface Props {
|
|
|
|
client: MatrixClient;
|
2022-08-05 16:16:59 -04:00
|
|
|
roomIdOrAlias: string;
|
2022-08-02 00:46:16 +02:00
|
|
|
viaServers: string[];
|
|
|
|
children: (groupCall: GroupCall) => ReactNode;
|
|
|
|
createPtt: boolean;
|
|
|
|
}
|
|
|
|
|
2022-07-11 13:23:03 +01:00
|
|
|
export function GroupCallLoader({
|
|
|
|
client,
|
2022-07-27 16:14:05 -04:00
|
|
|
roomIdOrAlias,
|
2022-07-11 13:23:03 +01:00
|
|
|
viaServers,
|
|
|
|
children,
|
2022-08-02 00:46:16 +02:00
|
|
|
createPtt,
|
|
|
|
}: Props): JSX.Element {
|
2022-10-10 09:19:10 -04:00
|
|
|
const { t } = useTranslation();
|
2022-03-03 16:56:45 -08:00
|
|
|
const { loading, error, groupCall } = useLoadGroupCall(
|
2022-01-05 15:35:12 -08:00
|
|
|
client,
|
2022-07-27 16:14:05 -04:00
|
|
|
roomIdOrAlias,
|
2022-03-03 16:56:45 -08:00
|
|
|
viaServers,
|
2022-07-11 13:23:03 +01:00
|
|
|
createPtt
|
2022-01-05 15:35:12 -08:00
|
|
|
);
|
|
|
|
|
2022-10-10 09:19:10 -04:00
|
|
|
usePageTitle(groupCall ? groupCall.room.name : t("Loading…"));
|
2022-02-02 15:02:40 -08:00
|
|
|
|
2022-01-05 15:35:12 -08:00
|
|
|
if (loading) {
|
|
|
|
return (
|
|
|
|
<FullScreenView>
|
2022-10-10 09:19:10 -04:00
|
|
|
<h1>{t("Loading room…")}</h1>
|
2022-01-05 15:35:12 -08:00
|
|
|
</FullScreenView>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
return <ErrorView error={error} />;
|
|
|
|
}
|
|
|
|
|
2022-08-02 00:46:16 +02:00
|
|
|
return <>{children(groupCall)}</>;
|
2022-01-05 15:35:12 -08:00
|
|
|
}
|