Skip to content

Commit

Permalink
feat: update drawio version and optimizing delete logic (#23)
Browse files Browse the repository at this point in the history
* feat: update drawio version

* feat: when multiple block reference same file, deleting one will not delete source file.

---------

Co-authored-by: [email protected] <lee>
  • Loading branch information
lee88688 authored Jul 17, 2024
1 parent a8ea81f commit acd7276
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drawio
Submodule drawio updated 802 files
18 changes: 17 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,23 @@ export const removeFile = async (e: LogseqDomEvent) => {
const fileName = e.dataset.fileName
const uuid = e.dataset.uuid

await storage.removeItem(fileName)
let isUnique = true
try {
const arr = await logseq.DB.datascriptQuery(
`[:find (pull ?b [*]) :where [?b :block/content ?content] [(clojure.string/includes? ?content "${createRenderer(fileName)}")]]`
)
if (arr.length > 1) {
isUnique = false
}
} catch (e) {
logseq.UI.showMsg(`Failed(${String(e)}) to query block!`, 'error')
return
}

if (isUnique) {
console.log('remove file', fileName)
await storage.removeItem(fileName)
}

const block = await logseq.Editor.getBlock(uuid)
if (!block) return
Expand Down

0 comments on commit acd7276

Please sign in to comment.