Skip to content

Build your personal knowledge base with Trilium Notes

put tabContext into frontend script API

zadam012a18be00cf
diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.html
index 62ff12f087..d04bc83324 100644
--- a/docs/frontend_api/services_frontend_script_api.js.html
+++ b/docs/frontend_api/services_frontend_script_api.js.html
@@ -311,7 +311,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
* @return {boolean} returns true if the original note is still loaded, false if user switched to another
*/
this.isNoteStillActive = () => {
- return this.originEntity.noteId === noteDetailService.getActiveNoteId();
+ return this.originEntity.noteId === tabContext.noteId;
};
/**
diff --git a/src/public/javascripts/services/bundle.js b/src/public/javascripts/services/bundle.js
index bcfa0b807f..13b01910d7 100644
--- a/src/public/javascripts/services/bundle.js
+++ b/src/public/javascripts/services/bundle.js
@@ -29,7 +29,7 @@ async function executeStartupBundles() {
}
}
-async function executeRelationBundles(note, relationName) {
+async function executeRelationBundles(note, relationName, tabContext) {
note.bundleCache = note.bundleCache || {};
if (!note.bundleCache[relationName]) {
@@ -37,7 +37,7 @@ async function executeRelationBundles(note, relationName) {
}
for (const bundle of note.bundleCache[relationName]) {
- await executeBundle(bundle, note);
+ await executeBundle(bundle, note, tabContext);
}
}
diff --git a/src/public/javascripts/services/frontend_script_api.js b/src/public/javascripts/services/frontend_script_api.js
index 281b9e8a47..aa72ad14cd 100644
--- a/src/public/javascripts/services/frontend_script_api.js
+++ b/src/public/javascripts/services/frontend_script_api.js
@@ -283,7 +283,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
* @return {boolean} returns true if the original note is still loaded, false if user switched to another
*/
this.isNoteStillActive = () => {
- return this.originEntity.noteId === noteDetailService.getActiveNoteId();
+ return this.originEntity.noteId === tabContext.noteId;
};
/**
diff --git a/src/public/javascripts/services/note_detail.js b/src/public/javascripts/services/note_detail.js
index b7ee2ea0a8..a20275a870 100644
--- a/src/public/javascripts/services/note_detail.js
+++ b/src/public/javascripts/services/note_detail.js
@@ -215,7 +215,7 @@ async function loadNoteDetailToContext(ctx, note, notePath) {
ctx.$scriptArea.empty();
- await bundleService.executeRelationBundles(ctx.note, 'runOnNoteView');
+ await bundleService.executeRelationBundles(ctx.note, 'runOnNoteView', ctx);
if (utils.isDesktop()) {
await ctx.attributes.showAttributes();
diff --git a/src/public/javascripts/services/tab_context.js b/src/public/javascripts/services/tab_context.js
index 4becfb2648..9165ff0121 100644
--- a/src/public/javascripts/services/tab_context.js
+++ b/src/public/javascripts/services/tab_context.js
@@ -235,7 +235,7 @@ class TabContext {
this.$savedIndicator.fadeIn();
// run async
- bundleService.executeRelationBundles(this.note, 'runOnNoteChange');
+ bundleService.executeRelationBundles(this.note, 'runOnNoteChange', this);
}
async saveNoteIfChanged() {