diff options
| author | MohamedBassem <me@mbassem.com> | 2025-04-07 01:03:26 +0100 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2025-04-08 03:48:12 -0700 |
| commit | 3207264fc13c275d6dcfbd2628cc6b3974ceeaed (patch) | |
| tree | d426ffe0fe6bc3b9e692d96af94aa8d5d2a51162 /apps/web/components/dashboard/preview/EditableTitle.tsx | |
| parent | 817eb58832a3e715e21892417b7624f4b1cf0d46 (diff) | |
| download | karakeep-3207264fc13c275d6dcfbd2628cc6b3974ceeaed.tar.zst | |
feat: Allow editing bookmark details
Diffstat (limited to 'apps/web/components/dashboard/preview/EditableTitle.tsx')
| -rw-r--r-- | apps/web/components/dashboard/preview/EditableTitle.tsx | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/apps/web/components/dashboard/preview/EditableTitle.tsx b/apps/web/components/dashboard/preview/EditableTitle.tsx deleted file mode 100644 index 03b95e74..00000000 --- a/apps/web/components/dashboard/preview/EditableTitle.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import { toast } from "@/components/ui/use-toast"; - -import { useUpdateBookmark } from "@hoarder/shared-react/hooks/bookmarks"; -import { BookmarkTypes, ZBookmark } from "@hoarder/shared/types/bookmarks"; - -import { EditableText } from "../EditableText"; - -export function EditableTitle({ bookmark }: { bookmark: ZBookmark }) { - const { mutate: updateBookmark, isPending } = useUpdateBookmark({ - onSuccess: () => { - toast({ - description: "Title updated!", - }); - }, - }); - - let title: string | null = null; - switch (bookmark.content.type) { - case BookmarkTypes.LINK: - title = bookmark.content.title ?? bookmark.content.url; - break; - case BookmarkTypes.TEXT: - title = null; - break; - case BookmarkTypes.ASSET: - title = bookmark.content.fileName ?? null; - break; - } - - title = bookmark.title ?? title; - if (title == "") { - title = null; - } - - return ( - <EditableText - originalText={title} - editClassName="p-2 text-lg break-all" - viewClassName="break-words line-clamp-2 text-lg text-ellipsis" - untitledClassName="text-lg italic text-gray-600" - onSave={(newTitle) => { - updateBookmark( - { - bookmarkId: bookmark.id, - title: newTitle, - }, - { - onError: () => { - toast({ - description: "Something went wrong", - variant: "destructive", - }); - }, - }, - ); - }} - isSaving={isPending} - /> - ); -} |
