Skip to content

Commit

Permalink
fix: Cases where we try to create an existing page
Browse files Browse the repository at this point in the history
  • Loading branch information
brunojm committed Jul 20, 2023
1 parent 92ec25b commit abff906
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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})`)
}
}
}
}
Expand Down

0 comments on commit abff906

Please sign in to comment.