From 532f22fe721b5738a2a602b7604ad80bdcbd2373 Mon Sep 17 00:00:00 2001 From: braladin Date: Sun, 6 Apr 2025 20:04:30 +0200 Subject: [PATCH] fix: Prevent multiple executions of db.onChanged callback When we change a block, multiple events get triggered and logseq.DB.onChanged gets called multiple (3) times. This commit adds a guard clause to prevent executing the callback function multiple times. --- index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/index.ts b/index.ts index e6ce4e3..3bdeb9d 100644 --- a/index.ts +++ b/index.ts @@ -149,6 +149,7 @@ const main = async () => { getPages(); dateFormat = (await logseq.App.getUserConfigs()).preferredDateFormat; logseq.DB.onChanged((e) => { + if (e.txMeta?.["skipRefresh?"] === true) return; if (e.txMeta?.outlinerOp == "insert-blocks" || e.txMeta?.outlinerOp == "insertBlocks") { if (logseq.settings?.enableAutoParse) { blockArray?.forEach(parseBlockForLink);