aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared-react
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2025-01-02 13:00:58 +0200
committerGitHub <noreply@github.com>2025-01-02 13:00:58 +0200
commit5ecdc36b7d60aa66b49e01e9fec8ba61ad537376 (patch)
tree57577822bb104b95900ba577a265fb4f8cf70b78 /packages/shared-react
parent5df0258b2cd884347eabfa866d7e7fbc7225cdb3 (diff)
downloadkarakeep-5ecdc36b7d60aa66b49e01e9fec8ba61ad537376.tar.zst
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>
Diffstat (limited to 'packages/shared-react')
-rw-r--r--packages/shared-react/hooks/bookmark-list-context.tsx27
-rw-r--r--packages/shared-react/hooks/lists.ts3
2 files changed, 30 insertions, 0 deletions
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<ZBookmarkList | undefined>(
+ undefined,
+);
+
+export function BookmarkListContextProvider({
+ list,
+ children,
+}: {
+ list: ZBookmarkList;
+ children: React.ReactNode;
+}) {
+ return (
+ <BookmarkListContext.Provider value={list}>
+ {children}
+ </BookmarkListContext.Provider>
+ );
+}
+
+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);
},
});