From 8c205249941bbd503ee452b0dd857f173bf74363 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sat, 23 Aug 2025 17:18:12 +0300 Subject: fix: Hide bookmark global actions when there's no bookmark grid shown --- apps/web/components/dashboard/GlobalActions.tsx | 10 +++++++--- apps/web/components/dashboard/bookmarks/BookmarksGrid.tsx | 9 +++++++++ apps/web/lib/store/useInBookmarkGridStore.ts | 11 +++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 apps/web/lib/store/useInBookmarkGridStore.ts (limited to 'apps') diff --git a/apps/web/components/dashboard/GlobalActions.tsx b/apps/web/components/dashboard/GlobalActions.tsx index d36b93d9..d385111a 100644 --- a/apps/web/components/dashboard/GlobalActions.tsx +++ b/apps/web/components/dashboard/GlobalActions.tsx @@ -3,13 +3,17 @@ import BulkBookmarksAction from "@/components/dashboard/BulkBookmarksAction"; import SortOrderToggle from "@/components/dashboard/SortOrderToggle"; import ViewOptions from "@/components/dashboard/ViewOptions"; +import { useInBookmarkGridStore } from "@/lib/store/useInBookmarkGridStore"; export default function GlobalActions() { + const inBookmarkGrid = useInBookmarkGridStore( + (state) => state.inBookmarkGrid, + ); return (
- - - + {inBookmarkGrid && } + {inBookmarkGrid && } + {inBookmarkGrid && }
); } diff --git a/apps/web/components/dashboard/bookmarks/BookmarksGrid.tsx b/apps/web/components/dashboard/bookmarks/BookmarksGrid.tsx index 954a7751..f726c703 100644 --- a/apps/web/components/dashboard/bookmarks/BookmarksGrid.tsx +++ b/apps/web/components/dashboard/bookmarks/BookmarksGrid.tsx @@ -2,6 +2,7 @@ import { useEffect, useMemo } from "react"; import NoBookmarksBanner from "@/components/dashboard/bookmarks/NoBookmarksBanner"; import { ActionButton } from "@/components/ui/action-button"; import useBulkActionsStore from "@/lib/bulkActions"; +import { useInBookmarkGridStore } from "@/lib/store/useInBookmarkGridStore"; import { bookmarkLayoutSwitch, useBookmarkLayout, @@ -62,6 +63,7 @@ export default function BookmarksGrid({ const layout = useBookmarkLayout(); const gridColumns = useGridColumns(); const bulkActionsStore = useBulkActionsStore(); + const inBookmarkGrid = useInBookmarkGridStore(); const breakpointConfig = useMemo( () => getBreakpointConfig(gridColumns), [gridColumns], @@ -75,6 +77,13 @@ export default function BookmarksGrid({ }; }, [bookmarks]); + useEffect(() => { + inBookmarkGrid.setInBookmarkGrid(true); + return () => { + inBookmarkGrid.setInBookmarkGrid(false); + }; + }, []); + useEffect(() => { if (loadMoreButtonInView && hasNextPage && !isFetchingNextPage) { fetchNextPage(); diff --git a/apps/web/lib/store/useInBookmarkGridStore.ts b/apps/web/lib/store/useInBookmarkGridStore.ts new file mode 100644 index 00000000..d534dc4c --- /dev/null +++ b/apps/web/lib/store/useInBookmarkGridStore.ts @@ -0,0 +1,11 @@ +import { create } from "zustand"; + +interface InBookmarkGridState { + inBookmarkGrid: boolean; + setInBookmarkGrid: (inBookmarkGrid: boolean) => void; +} + +export const useInBookmarkGridStore = create((set) => ({ + inBookmarkGrid: false, + setInBookmarkGrid: (inBookmarkGrid) => set({ inBookmarkGrid }), +})); -- cgit v1.2.3-70-g09d2