From 5ecdc36b7d60aa66b49e01e9fec8ba61ad537376 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Thu, 2 Jan 2025 13:00:58 +0200 Subject: feat: Add support for smart lists (#802) * feat: Add support for smart lists * i18n * Fix update list endpoint * Add a test for smart lists * Add header to the query explainer * Hide remove from lists in the smart context list * Add proper validation to list form --------- Co-authored-by: Deepak Kapoor <41769111+orthdron@users.noreply.github.com> --- .../shared-react/hooks/bookmark-list-context.tsx | 27 ++++++++++++++++++++++ packages/shared-react/hooks/lists.ts | 3 +++ 2 files changed, 30 insertions(+) create mode 100644 packages/shared-react/hooks/bookmark-list-context.tsx (limited to 'packages/shared-react') diff --git a/packages/shared-react/hooks/bookmark-list-context.tsx b/packages/shared-react/hooks/bookmark-list-context.tsx new file mode 100644 index 00000000..d00e0567 --- /dev/null +++ b/packages/shared-react/hooks/bookmark-list-context.tsx @@ -0,0 +1,27 @@ +"use client"; + +import { createContext, useContext } from "react"; + +import { ZBookmarkList } from "@hoarder/shared/types/lists"; + +export const BookmarkListContext = createContext( + undefined, +); + +export function BookmarkListContextProvider({ + list, + children, +}: { + list: ZBookmarkList; + children: React.ReactNode; +}) { + return ( + + {children} + + ); +} + +export function useBookmarkListContext() { + return useContext(BookmarkListContext); +} diff --git a/packages/shared-react/hooks/lists.ts b/packages/shared-react/hooks/lists.ts index 10633a08..46477228 100644 --- a/packages/shared-react/hooks/lists.ts +++ b/packages/shared-react/hooks/lists.ts @@ -28,6 +28,9 @@ export function useEditBookmarkList( onSuccess: (res, req, meta) => { apiUtils.lists.list.invalidate(); apiUtils.lists.get.invalidate({ listId: req.listId }); + if (res.type === "smart") { + apiUtils.bookmarks.getBookmarks.invalidate({ listId: req.listId }); + } return opts[0]?.onSuccess?.(res, req, meta); }, }); -- cgit v1.2.3-70-g09d2