From 896f3700d06d95abba5ef6e9e5f7e477a153c834 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 14 Mar 2022 18:35:37 -0700 Subject: [PATCH] fix: Cannot useCurrentUser in Sidebar as it is used unauthenticated on shares --- app/components/Sidebar/Sidebar.tsx | 39 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/app/components/Sidebar/Sidebar.tsx b/app/components/Sidebar/Sidebar.tsx index 192d58876..718380a4e 100644 --- a/app/components/Sidebar/Sidebar.tsx +++ b/app/components/Sidebar/Sidebar.tsx @@ -6,7 +6,6 @@ import { useLocation } from "react-router-dom"; import styled, { useTheme } from "styled-components"; import breakpoint from "styled-components-breakpoint"; import Flex from "~/components/Flex"; -import useCurrentUser from "~/hooks/useCurrentUser"; import useMenuContext from "~/hooks/useMenuContext"; import usePrevious from "~/hooks/usePrevious"; import useStores from "~/hooks/useStores"; @@ -28,11 +27,11 @@ const Sidebar = React.forwardRef( const [isCollapsing, setCollapsing] = React.useState(false); const theme = useTheme(); const { t } = useTranslation(); - const { ui } = useStores(); + const { ui, auth } = useStores(); const location = useLocation(); const previousLocation = usePrevious(location); const { isMenuOpen } = useMenuContext(); - const user = useCurrentUser(); + const { user } = auth; const width = ui.sidebarWidth; const collapsed = (ui.isEditing || ui.sidebarCollapsed) && !isMenuOpen; @@ -169,22 +168,24 @@ const Sidebar = React.forwardRef( )} {children} - - {(props) => ( - - } - /> - )} - + {user && ( + + {(props) => ( + + } + /> + )} + + )}