From 43ed698930531631116f0fc22234a9ef68c122e6 Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Sun, 13 Oct 2024 12:22:33 +0000
Subject: fix: Add support for importing notes from the hoarder export

---
 .../components/dashboard/settings/ImportExport.tsx   | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

(limited to 'apps/web/components/dashboard/settings/ImportExport.tsx')

diff --git a/apps/web/components/dashboard/settings/ImportExport.tsx b/apps/web/components/dashboard/settings/ImportExport.tsx
index f3ef13ef..1145a42d 100644
--- a/apps/web/components/dashboard/settings/ImportExport.tsx
+++ b/apps/web/components/dashboard/settings/ImportExport.tsx
@@ -64,14 +64,20 @@ export function ImportExportRow() {
       listId: string;
     }) => {
       const bookmark = toImport.bookmark;
-      if (bookmark.url === undefined) {
-        throw new Error("URL is undefined");
+      if (bookmark.content === undefined) {
+        throw new Error("Content is undefined");
       }
-      new URL(bookmark.url);
-      const created = await createBookmark({
-        type: BookmarkTypes.LINK,
-        url: bookmark.url,
-      });
+      const created = await createBookmark(
+        bookmark.content.type === BookmarkTypes.LINK
+          ? {
+              type: BookmarkTypes.LINK,
+              url: bookmark.content.url,
+            }
+          : {
+              type: BookmarkTypes.TEXT,
+              text: bookmark.content.text,
+            },
+      );
 
       await Promise.all([
         // Update title and createdAt if they're set
-- 
cgit v1.2.3-70-g09d2

