fix: redirect to / on empty invites

This commit is contained in:
goat 2021-09-08 19:35:53 +02:00
parent 4787a2166f
commit 8185b59771
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5
2 changed files with 4 additions and 2 deletions

View file

@ -121,7 +121,7 @@ export default function App() {
<Route path="/friends" component={Friends} />
<Route path="/open/:id" component={Open} />
<Route path="/bot/:id" component={InviteBot} />
<Route path="/invite/:code" component={Invite} />
<Route path="/invite/:code?" component={Invite} />
<Route path="/" component={Home} />
</Switch>
</Routes>

View file

@ -1,6 +1,6 @@
import { ArrowBack } from "@styled-icons/boxicons-regular";
import { autorun } from "mobx";
import { useHistory, useParams } from "react-router-dom";
import { Redirect, useHistory, useParams } from "react-router-dom";
import { RetrievedInvite } from "revolt-api/types/Invites";
import styles from "./Invite.module.scss";
@ -49,6 +49,8 @@ export default function Invite() {
}
}, [client, code, invite, status]);
if (code === undefined) return <Redirect to="/" />;
if (typeof invite === "undefined") {
return (
<div className={styles.preloader}>