Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix preserving original sourceId after running script notes, fixes #2224
zadam6738f2cd24fa
diff --git a/package-lock.json b/package-lock.jsonindex 0fc7a875c2..5e8b99b119 100644--- a/package-lock.json+++ b/package-lock.json@@ -1344,9 +1344,9 @@"integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ=="},"axios": {- "version": "0.22.0",- "resolved": "https://registry.npmjs.org/axios/-/axios-0.22.0.tgz",- "integrity": "sha512-Z0U3uhqQeg1oNcihswf4ZD57O3NrR1+ZXhxaROaWpDmsDTx7T2HNBV2ulBtie2hwJptu8UvgnJoK+BIqdzh/1w==",+ "version": "0.23.0",+ "resolved": "https://registry.npmjs.org/axios/-/axios-0.23.0.tgz",+ "integrity": "sha512-NmvAE4i0YAv5cKq8zlDoPd1VLKAqX5oLuZKs8xkJa4qi6RGn0uhCYFjWtHHC9EM/MwOwYWOs53W+V0aqEXq1sg==","requires": {"follow-redirects": "^1.14.4"}diff --git a/src/services/script.js b/src/services/script.jsindex 4a861f11e5..771b491587 100644--- a/src/services/script.js+++ b/src/services/script.js@@ -30,11 +30,12 @@ function executeBundle(bundle, apiParams = {}) {apiParams.startNote = bundle.note;}+ const originalSourceId = cls.get('sourceId');+cls.set('sourceId', 'script');// last \r\n is necessary if script contains line comment on its last lineconst script = "function() {\r\n" + bundle.script + "\r\n}";-const ctx = new ScriptContext(bundle.allNotes, apiParams);try {@@ -45,6 +46,9 @@ function executeBundle(bundle, apiParams = {}) {throw e;}+ finally {+ cls.set('sourceId', originalSourceId);+ }}/**