diff options
| author | MohamedBassem <me@mbassem.com> | 2025-05-24 10:31:53 +0100 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2025-05-24 10:31:53 +0100 |
| commit | c6d21afa17775270bb8e65dd1b6df09023147f01 (patch) | |
| tree | e305a3cafcf0a2796db2c8d22da7950e353343f6 /apps | |
| parent | 6af14e9d0ab76ad2a1b92e0072d8242129910d3e (diff) | |
| download | karakeep-c6d21afa17775270bb8e65dd1b6df09023147f01.tar.zst | |
feat: Read the archive status from omnivore and pocket. Fixes #703
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/web/components/settings/ImportExport.tsx | 1 | ||||
| -rw-r--r-- | apps/web/lib/exportBookmarks.ts | 2 | ||||
| -rw-r--r-- | apps/web/lib/importBookmarkParser.ts | 10 |
3 files changed, 13 insertions, 0 deletions
diff --git a/apps/web/components/settings/ImportExport.tsx b/apps/web/components/settings/ImportExport.tsx index e2678bbc..a20bd554 100644 --- a/apps/web/components/settings/ImportExport.tsx +++ b/apps/web/components/settings/ImportExport.tsx @@ -137,6 +137,7 @@ export function ImportExportRow() { ? new Date(bookmark.addDate * 1000) : undefined, note: bookmark.notes, + archived: bookmark.archived, ...(bookmark.content.type === BookmarkTypes.LINK ? { type: BookmarkTypes.LINK, diff --git a/apps/web/lib/exportBookmarks.ts b/apps/web/lib/exportBookmarks.ts index 67b0b5da..5dc26e78 100644 --- a/apps/web/lib/exportBookmarks.ts +++ b/apps/web/lib/exportBookmarks.ts @@ -19,6 +19,7 @@ export const zExportBookmarkSchema = z.object({ ]) .nullable(), note: z.string().nullable(), + archived: z.boolean().optional().default(false), }); export const zExportSchema = z.object({ @@ -56,6 +57,7 @@ export function toExportFormat( tags: bookmark.tags.map((t) => t.name), content, note: bookmark.note ?? null, + archived: bookmark.archived, }; } diff --git a/apps/web/lib/importBookmarkParser.ts b/apps/web/lib/importBookmarkParser.ts index a97e4da9..aba11689 100644 --- a/apps/web/lib/importBookmarkParser.ts +++ b/apps/web/lib/importBookmarkParser.ts @@ -15,6 +15,7 @@ export interface ParsedBookmark { tags: string[]; addDate?: number; notes?: string; + archived?: boolean; } export async function parseNetscapeBookmarkFile( @@ -64,6 +65,7 @@ export async function parsePocketBookmarkFile( url: string; time_added: string; tags: string; + status?: string; }[]; return records.map((record) => { @@ -72,6 +74,7 @@ export async function parsePocketBookmarkFile( content: { type: BookmarkTypes.LINK as const, url: record.url }, tags: record.tags.length > 0 ? record.tags.split("|") : [], addDate: parseInt(record.time_added), + archived: record.status === "archive", }; }); } @@ -107,6 +110,7 @@ export async function parseKarakeepBookmarkFile( tags: bookmark.tags, addDate: bookmark.createdAt, notes: bookmark.note ?? undefined, + archived: bookmark.archived, }; }); } @@ -121,6 +125,7 @@ export async function parseOmnivoreBookmarkFile( url: z.string(), labels: z.array(z.string()), savedAt: z.coerce.date(), + state: z.string().optional(), }), ); @@ -137,6 +142,7 @@ export async function parseOmnivoreBookmarkFile( content: { type: BookmarkTypes.LINK as const, url: bookmark.url }, tags: bookmark.labels, addDate: bookmark.savedAt.getTime() / 1000, + archived: bookmark.state === "Archived", }; }); } @@ -242,6 +248,10 @@ export function deduplicateBookmarks( } else if (bookmark.notes) { existing.notes = bookmark.notes; } + // For archived status, prefer archived if either is archived + if (bookmark.archived === true) { + existing.archived = true; + } // Title: keep existing one for simplicity } else { deduplicatedBookmarksMap.set(url, bookmark); |
