A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: fix tags & colors not included in imported notes (#5801)
Ammar Ahmed1c70ad8ceccb
diff --git a/apps/web/src/utils/importer.ts b/apps/web/src/utils/importer.tsindex 562cacc0c..8635671ec 100644--- a/apps/web/src/utils/importer.ts+++ b/apps/web/src/utils/importer.ts@@ -89,6 +89,21 @@ async function processAttachment(attachments[name] = { ...cipherData, key };}+const colorMap: Record<string, string | undefined> = {+ default: undefined,+ teal: "#00897B",+ red: "#D32F2F",+ purple: "#7B1FA2",+ blue: "#1976D2",+ cerulean: "#03A9F4",+ pink: "#C2185B",+ brown: "#795548",+ gray: "#9E9E9E",+ green: "#388E3C",+ orange: "#FFA000",+ yellow: "#FFC107"+};+async function processNote(entry: ZipEntry, attachments: Record<string, any>) {const note = await fileToJson<Note>(entry);for (const attachment of note.attachments || []) {@@ -121,8 +136,49 @@ async function processNote(entry: ZipEntry, attachments: Record<string, any>) {content: { type: "tiptap", data: note.content?.data },notebooks: []});+if (!noteId) return;+ for (const tag of note.tags || []) {+ const tagId =+ (await db.tags.find(tag))?.id ||+ (await db.tags.add({+ title: tag+ }));++ await db.relations.add(+ {+ id: tagId,+ type: "tag"+ },+ {+ id: noteId,+ type: "note"+ }+ );+ }++ const colorCode = note.color ? colorMap[note.color] : undefined;+ if (colorCode) {+ const colorId =+ (await db.colors.find(colorCode))?.id ||+ (await db.colors.add({+ colorCode: colorCode,+ title: note.color+ }));++ await db.relations.add(+ {+ id: colorId,+ type: "color"+ },+ {+ id: noteId,+ type: "note"+ }+ );+ }+for (const nb of notebooks) {const notebookId = await importNotebook(nb).catch(() => undefined);if (!notebookId) continue;