From abff9069c3abeebad1b03498719a1b1f12a0d494 Mon Sep 17 00:00:00 2001 From: Bruno Melo Date: Thu, 20 Jul 2023 20:18:17 -0300 Subject: [PATCH] fix: Cases where we try to create an existing page --- src/main.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index b54d01f..4ab7d49 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -390,10 +390,17 @@ async function downloadArchive(exportID: number, setNotification?, setIsSyncing? } else { if (convertedBook !== undefined) { - const page = await createPage(bookData.title, convertedBook!.children!) - if (page) { - booksIDsMap[bookId] = page.uuid - setNotification(`Creating "${bookData.title}" completed (${index}/${books.length})`) + const existing_page = await logseq.Editor.getPage(bookData.title) + if (existing_page !== null) { + booksIDsMap[bookId] = existing_page.uuid + setNotification(`Skipping "${bookData.title}" (already created) (${index}/${books.length})`) + } else { + // page doesn't exist, so we create it + const page = await createPage(bookData.title, convertedBook!.children!) + if (page) { + booksIDsMap[bookId] = page.uuid + setNotification(`Creating "${bookData.title}" completed (${index}/${books.length})`) + } } } }