From ec76be776c0fa27dda597885ddce77308880e1ba Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Fri, 17 Mar 2023 14:07:29 +0500 Subject: [PATCH] web: make topics optional in importer --- apps/web/src/utils/importer.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/apps/web/src/utils/importer.ts b/apps/web/src/utils/importer.ts index 734d3c3fd..32c0afd04 100644 --- a/apps/web/src/utils/importer.ts +++ b/apps/web/src/utils/importer.ts @@ -116,17 +116,11 @@ async function importNotebook(notebook: Notebook) { if (!nb) { const nbId = await db.notebooks?.add({ title: notebook.notebook, - topics: [notebook.topic] + topics: notebook.topic ? [notebook.topic] : [] }); nb = db.notebooks?.notebook(nbId).data; } - - let topic = nb?.topics.find((t: any) => t.title === notebook.topic); - if (!topic) { - const topics = db.notebooks?.notebook(nb).topics; - await topics?.add(notebook.topic); - topic = topics?.all.find((t) => t.title === notebook.topic); - } + const topic = nb?.topics.find((t: any) => t.title === notebook.topic); return { id: nb.id, topic: topic.id }; }