Skip to content

Commit

Permalink
Merge pull request #12 from omnivore-app/update-existing-article-blocks
Browse files Browse the repository at this point in the history
Remove the existing article blocks and insert new one if it is updated
  • Loading branch information
sywhb authored Jun 24, 2022
2 parents 9c4167a + 19f70f2 commit b24842d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ const fetchOmnivore = async (
date:: ${new Date(savedAt).toDateString()}
> ${description}`

// remove existing block for the same article
const existingBlocks = await logseq.DB.q<BlockEntity>(`"${slug}"`)
if (existingBlocks && existingBlocks.length > 0) {
console.log(existingBlocks)
for (const block of existingBlocks) {
await logseq.Editor.removeBlock(block.uuid)
}
}

const articleBlock = await logseq.Editor.insertBlock(
targetBlock.uuid,
content,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logseq-omnivore",
"version": "1.4.2",
"version": "1.4.3",
"description": "Import Omnivore highlights and articles into Logseq.",
"main": "dist/index.html",
"targets": {
Expand Down

0 comments on commit b24842d

Please sign in to comment.