Handle broken links better

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner
2023-07-29 20:31:18 +02:00
parent f0c22c429d
commit a0bf1d2677
2 changed files with 27 additions and 8 deletions

View File

@@ -15,7 +15,6 @@ limitations under the License.
*/
import { FC, useEffect, useState, useCallback } from "react";
import { useTranslation } from "react-i18next";
import type { GroupCall } from "matrix-js-sdk/src/webrtc/groupCall";
import { useClientLegacy } from "../ClientContext";
@@ -25,11 +24,11 @@ import { GroupCallLoader } from "./GroupCallLoader";
import { GroupCallView } from "./GroupCallView";
import { useUrlParams } from "../UrlParams";
import { useRegisterPasswordlessUser } from "../auth/useRegisterPasswordlessUser";
import { translatedError } from "../TranslatedError";
import { useOptInAnalytics } from "../settings/useSetting";
import { useHistory } from "react-router-dom";
export const RoomPage: FC = () => {
const { t } = useTranslation();
const history = useHistory();
const {
roomAlias,
@@ -42,7 +41,11 @@ export const RoomPage: FC = () => {
displayName,
} = useUrlParams();
const roomIdOrAlias = roomId ?? roomAlias;
if (!roomIdOrAlias) throw translatedError("No room specified", t);
if (!roomIdOrAlias) {
history.push("/");
console.error("No room specified");
return null;
}
const [optInAnalytics, setOptInAnalytics] = useOptInAnalytics();
const { registerPasswordlessUser } = useRegisterPasswordlessUser();