From 8bf488de0b85afe478bbd657594d5a05dfba2cb7 Mon Sep 17 00:00:00 2001 From: Apoorv Mishra Date: Fri, 9 Aug 2024 01:22:20 +0530 Subject: [PATCH] Fetch collections upon initial load (#7358) * fix: don't hide sidebar if collections are not loaded, loading drafts should be enough * fix: preload collections * fix: remove duplicate API call --- app/components/Sidebar/App.tsx | 5 +++-- app/components/Sidebar/components/Collections.tsx | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/components/Sidebar/App.tsx b/app/components/Sidebar/App.tsx index b7a3aac453..8ea1561338 100644 --- a/app/components/Sidebar/App.tsx +++ b/app/components/Sidebar/App.tsx @@ -34,7 +34,7 @@ import TrashLink from "./components/TrashLink"; function AppSidebar() { const { t } = useTranslation(); - const { documents, ui } = useStores(); + const { documents, ui, collections } = useStores(); const team = useCurrentTeam(); const user = useCurrentUser(); const can = usePolicy(team); @@ -42,8 +42,9 @@ function AppSidebar() { React.useEffect(() => { if (!user.isViewer) { void documents.fetchDrafts(); + void collections.fetchAll(); } - }, [documents, user.isViewer]); + }, [documents, collections, user.isViewer]); const [dndArea, setDndArea] = React.useState(); const handleSidebarRef = React.useCallback((node) => setDndArea(node), []); diff --git a/app/components/Sidebar/components/Collections.tsx b/app/components/Sidebar/components/Collections.tsx index 0c3d3b77e4..1b5419b31d 100644 --- a/app/components/Sidebar/components/Collections.tsx +++ b/app/components/Sidebar/components/Collections.tsx @@ -53,7 +53,6 @@ function Collections() {