2022-01-05 23:06:51 +00:00
|
|
|
import React, { useEffect } from "react";
|
|
|
|
import { useLocation, useHistory } from "react-router-dom";
|
2022-01-06 01:19:03 +00:00
|
|
|
import { defaultHomeserverHost } from "../matrix-utils";
|
2022-01-05 23:06:51 +00:00
|
|
|
import { LoadingView } from "../FullScreenView";
|
|
|
|
|
|
|
|
export function RoomRedirect() {
|
|
|
|
const { pathname } = useLocation();
|
|
|
|
const history = useHistory();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
let roomId = pathname;
|
|
|
|
|
|
|
|
if (pathname.startsWith("/")) {
|
2022-02-14 20:35:39 +00:00
|
|
|
roomId = roomId.substring(1, roomId.length);
|
2022-01-05 23:06:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!roomId.startsWith("#") && !roomId.startsWith("!")) {
|
|
|
|
roomId = `#${roomId}:${defaultHomeserverHost}`;
|
|
|
|
}
|
|
|
|
|
2022-03-04 00:56:45 +00:00
|
|
|
history.replace(`/room/${roomId.toLowerCase()}`);
|
2022-01-05 23:06:51 +00:00
|
|
|
}, [pathname, history]);
|
|
|
|
|
|
|
|
return <LoadingView />;
|
|
|
|
}
|