From 6e90035fa811180a59465b5e79987bafef302d59 Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Wed, 27 Mar 2024 17:24:46 +0000
Subject: fix: Refresh the search cache when a bookmark is deleted. Fixes #26

---
 apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx')

diff --git a/apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx b/apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx
index a639b949..e95ec9a2 100644
--- a/apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx
+++ b/apps/web/components/dashboard/bookmarks/BookmarkOptions.tsx
@@ -52,6 +52,9 @@ export default function BookmarkOptions({ bookmark }: { bookmark: ZBookmark }) {
   const invalidateBookmarkCache =
     api.useUtils().bookmarks.getBookmark.invalidate;
 
+  const invalidateSearchCache =
+    api.useUtils().bookmarks.searchBookmarks.invalidate;
+
   const onError = () => {
     toast({
       variant: "destructive",
@@ -68,6 +71,7 @@ export default function BookmarkOptions({ bookmark }: { bookmark: ZBookmark }) {
     onError,
     onSettled: () => {
       invalidateAllBookmarksCache();
+      invalidateSearchCache();
     },
   });
 
@@ -81,6 +85,7 @@ export default function BookmarkOptions({ bookmark }: { bookmark: ZBookmark }) {
     onSettled: () => {
       invalidateBookmarkCache({ bookmarkId: bookmark.id });
       invalidateAllBookmarksCache();
+      invalidateSearchCache();
     },
   });
 
-- 
cgit v1.2.3-70-g09d2

