From b5077b62ff1b1771944a9c1ddae79f5cec8859b4 Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Tue, 28 Dec 2021 12:24:35 +0000 Subject: [PATCH] fix(invite): allow logged out users to view invites --- src/context/revoltjs/CheckAuth.tsx | 4 ++++ src/lib/FakeClient.tsx | 8 +++++--- src/pages/RevoltApp.tsx | 2 -- src/pages/app.tsx | 15 ++++++++++----- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/context/revoltjs/CheckAuth.tsx b/src/context/revoltjs/CheckAuth.tsx index 4064d264..3d76ae92 100644 --- a/src/context/revoltjs/CheckAuth.tsx +++ b/src/context/revoltjs/CheckAuth.tsx @@ -7,6 +7,8 @@ import { useClient } from "./RevoltClient"; interface Props { auth?: boolean; + blockRender?: boolean; + children: Children; } @@ -16,8 +18,10 @@ export const CheckAuth = (props: Props) => { const ready = auth.isLoggedIn() && !!client?.user; if (props.auth && !ready) { + if (props.blockRender) return null; return ; } else if (!props.auth && ready) { + if (props.blockRender) return null; return ; } diff --git a/src/lib/FakeClient.tsx b/src/lib/FakeClient.tsx index 2eb95126..d2523ef5 100644 --- a/src/lib/FakeClient.tsx +++ b/src/lib/FakeClient.tsx @@ -1,3 +1,5 @@ +import { observer } from "mobx-react-lite"; + import { useMemo } from "preact/hooks"; import { useApplicationState } from "../mobx/State"; @@ -6,8 +8,8 @@ import { AppContext } from "../context/revoltjs/RevoltClient"; import { Children } from "../types/Preact"; -export default function FakeClient({ children }: { children: Children }) { +export default observer(({ children }: { children: Children }) => { const config = useApplicationState().config; - const client = useMemo(() => config.createClient(), []); + const client = useMemo(() => config.createClient(), [config.get()]); return {children}; -} +}); diff --git a/src/pages/RevoltApp.tsx b/src/pages/RevoltApp.tsx index bd82df73..296a556a 100644 --- a/src/pages/RevoltApp.tsx +++ b/src/pages/RevoltApp.tsx @@ -19,7 +19,6 @@ import Channel from "./channels/Channel"; import Developer from "./developer/Developer"; import Friends from "./friends/Friends"; import Home from "./home/Home"; -import Invite from "./invite/Invite"; import InviteBot from "./invite/InviteBot"; import ChannelSettings from "./settings/ChannelSettings"; import ServerSettings from "./settings/ServerSettings"; @@ -121,7 +120,6 @@ export default function App() { - diff --git a/src/pages/app.tsx b/src/pages/app.tsx index d5b4ee26..4fb2093a 100644 --- a/src/pages/app.tsx +++ b/src/pages/app.tsx @@ -31,6 +31,16 @@ export function App() { + + + + + + + + + + @@ -41,11 +51,6 @@ export function App() { - - - - -