aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components/dashboard/settings/ImportExport.tsx
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-10-13 12:22:33 +0000
committerMohamedBassem <me@mbassem.com>2024-10-13 12:22:33 +0000
commit43ed698930531631116f0fc22234a9ef68c122e6 (patch)
tree2010f230e2bcb4112c99e3c1853eb607d48fe2d1 /apps/web/components/dashboard/settings/ImportExport.tsx
parentcdd0088a7f1d1978b6fa84c7bd2ab12636214227 (diff)
downloadkarakeep-43ed698930531631116f0fc22234a9ef68c122e6.tar.zst
fix: Add support for importing notes from the hoarder export
Diffstat (limited to 'apps/web/components/dashboard/settings/ImportExport.tsx')
-rw-r--r--apps/web/components/dashboard/settings/ImportExport.tsx20
1 files changed, 13 insertions, 7 deletions
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