From 7c04276bacf6e9ecc0cce4a2ece7a25dc8e5deaa Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Tue, 20 Feb 2024 14:05:53 +0000
Subject: ui: hydrate the react query cache in the client side components

---
 packages/web/app/dashboard/bookmarks/components/AddLink.tsx | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

(limited to 'packages/web/app/dashboard/bookmarks/components/AddLink.tsx')

diff --git a/packages/web/app/dashboard/bookmarks/components/AddLink.tsx b/packages/web/app/dashboard/bookmarks/components/AddLink.tsx
index 6498b313..7663543f 100644
--- a/packages/web/app/dashboard/bookmarks/components/AddLink.tsx
+++ b/packages/web/app/dashboard/bookmarks/components/AddLink.tsx
@@ -3,7 +3,6 @@
 import { Form, FormControl, FormField, FormItem } from "@/components/ui/form";
 import { Input } from "@/components/ui/input";
 import { Plus } from "lucide-react";
-import { useRouter } from "next/navigation";
 import { useForm, SubmitErrorHandler } from "react-hook-form";
 import { z } from "zod";
 import { zodResolver } from "@hookform/resolvers/zod";
@@ -17,14 +16,14 @@ const formSchema = z.object({
 });
 
 export default function AddLink() {
-  const router = useRouter();
   const { setLoading } = useLoadingCard();
+  const invalidateBookmarksCache = api.useUtils().bookmarks.invalidate;
   const bookmarkLinkMutator = api.bookmarks.bookmarkLink.useMutation({
     onMutate: () => {
       setLoading(true);
     },
     onSuccess: () => {
-      router.refresh();
+      invalidateBookmarksCache();
     },
     onError: () => {
       toast({ description: "Something went wrong", variant: "destructive" });
-- 
cgit v1.2.3-70-g09d2

