From cf67c78823bd1e7591c2199d51aa3f3fffed73c4 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Thu, 18 Jun 2020 18:44:52 +0100 Subject: Refactor webui changes. Don't use contexts, just raw Apollo, since it's cached anyway. Change "ReadonlyHidden" to "IfLoggedIn". --- webui/src/layout/IfLoggedIn.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 webui/src/layout/IfLoggedIn.tsx (limited to 'webui/src/layout/IfLoggedIn.tsx') diff --git a/webui/src/layout/IfLoggedIn.tsx b/webui/src/layout/IfLoggedIn.tsx new file mode 100644 index 00000000..8b9058dc --- /dev/null +++ b/webui/src/layout/IfLoggedIn.tsx @@ -0,0 +1,14 @@ +import React from 'react'; + +import { useCurrentIdentityQuery } from './CurrentIdentity.generated'; + +type Props = { children: React.ReactNode }; +const IfLoggedIn = ({ children }: Props) => { + const { loading, error, data } = useCurrentIdentityQuery(); + + if (error || loading || !data?.repository?.userIdentity) return null; + + return <>{children}; +}; + +export default IfLoggedIn; -- cgit