From 012a18be00cf10976baa93cffeca1dbbbd1a13c5 Mon Sep 17 00:00:00 2001 From: zadam Date: Wed, 29 May 2019 21:48:48 +0200 Subject: [PATCH] put tabContext into frontend script API --- docs/frontend_api/services_frontend_script_api.js.html | 2 +- src/public/javascripts/services/bundle.js | 4 ++-- src/public/javascripts/services/frontend_script_api.js | 2 +- src/public/javascripts/services/note_detail.js | 2 +- src/public/javascripts/services/tab_context.js | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/frontend_api/services_frontend_script_api.js.html b/docs/frontend_api/services_frontend_script_api.js.html index 62ff12f08..d04bc8332 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 bcfa0b807..13b01910d 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 281b9e8a4..aa72ad14c 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 b7ee2ea0a..a20275a87 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 4becfb264..9165ff012 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() {