From 50c3c5e132643fc33d39fb9dc1fe951efe766337 Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Wed, 14 Feb 2024 01:26:45 +0000
Subject: feature: Add ability to refresh bookmark details

---
 .../bookmarks/components/BookmarkOptions.tsx       | 25 +++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

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

diff --git a/packages/web/app/dashboard/bookmarks/components/BookmarkOptions.tsx b/packages/web/app/dashboard/bookmarks/components/BookmarkOptions.tsx
index 4496d820..4123dc36 100644
--- a/packages/web/app/dashboard/bookmarks/components/BookmarkOptions.tsx
+++ b/packages/web/app/dashboard/bookmarks/components/BookmarkOptions.tsx
@@ -11,7 +11,7 @@ import {
   DropdownMenuItem,
   DropdownMenuTrigger,
 } from "@/components/ui/dropdown-menu";
-import { Archive, MoreHorizontal, Star, Trash2 } from "lucide-react";
+import { Archive, MoreHorizontal, RotateCw, Star, Trash2 } from "lucide-react";
 
 export default function BookmarkOptions({ bookmark }: { bookmark: ZBookmark }) {
   const { toast } = useToast();
@@ -55,6 +55,25 @@ export default function BookmarkOptions({ bookmark }: { bookmark: ZBookmark }) {
     router.refresh();
   };
 
+  const crawlBookmark = async () => {
+    try {
+      await api.bookmarks.recrawlBookmark.mutate({
+        bookmarkId: linkId,
+      });
+      toast({
+        description: "Re-fetch has been enqueued!",
+      });
+    } catch (e) {
+      toast({
+        variant: "destructive",
+        title: "Something went wrong",
+        description: "There was a problem with your request.",
+      });
+    }
+
+    router.refresh();
+  };
+
   return (
     <DropdownMenu>
       <DropdownMenuTrigger asChild>
@@ -82,6 +101,10 @@ export default function BookmarkOptions({ bookmark }: { bookmark: ZBookmark }) {
           <Archive className="mr-2 size-4" />
           <span>{bookmark.archived ? "Un-archive" : "Archive"}</span>
         </DropdownMenuItem>
+        <DropdownMenuItem onClick={crawlBookmark}>
+          <RotateCw className="mr-2 size-4" />
+          <span>Refresh</span>
+        </DropdownMenuItem>
         <DropdownMenuItem className="text-destructive" onClick={unbookmarkLink}>
           <Trash2 className="mr-2 size-4" />
           <span>Delete</span>
-- 
cgit v1.2.3-70-g09d2

