mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
runOnNoteChange fires also on the frontend, closes #340
This commit is contained in:
parent
35edce7523
commit
19d8947123
@ -30,9 +30,13 @@ async function executeStartupBundles() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function executeRelationBundles(note, relationName) {
|
async function executeRelationBundles(note, relationName) {
|
||||||
const bundlesToRun = await server.get("script/relation/" + note.noteId + "/" + relationName);
|
note.bundleCache = note.bundleCache || {};
|
||||||
|
|
||||||
for (const bundle of bundlesToRun) {
|
if (!note.bundleCache[relationName]) {
|
||||||
|
note.bundleCache[relationName] = await server.get("script/relation/" + note.noteId + "/" + relationName);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const bundle of note.bundleCache[relationName]) {
|
||||||
await executeBundle(bundle, note);
|
await executeBundle(bundle, note);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,9 @@ async function saveNote() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$savedIndicator.fadeIn();
|
$savedIndicator.fadeIn();
|
||||||
|
|
||||||
|
// run async
|
||||||
|
bundleService.executeRelationBundles(getCurrentNote(), 'runOnNoteChange');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveNoteIfChanged() {
|
async function saveNoteIfChanged() {
|
||||||
|
@ -54,6 +54,11 @@ async function getRelationBundles(req) {
|
|||||||
|
|
||||||
for (const noteId of uniqueNoteIds) {
|
for (const noteId of uniqueNoteIds) {
|
||||||
const note = await repository.getNote(noteId);
|
const note = await repository.getNote(noteId);
|
||||||
|
|
||||||
|
if (!note.isJavaScript() || note.getScriptEnv() !== 'frontend') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const bundle = await scriptService.getScriptBundleForFrontend(note);
|
const bundle = await scriptService.getScriptBundleForFrontend(note);
|
||||||
|
|
||||||
if (bundle) {
|
if (bundle) {
|
||||||
|
@ -6,7 +6,7 @@ const sourceIdService = require('./source_id');
|
|||||||
const log = require('./log');
|
const log = require('./log');
|
||||||
|
|
||||||
async function executeNote(note, originEntity) {
|
async function executeNote(note, originEntity) {
|
||||||
if (!note.isJavaScript() || !note.isContentAvailable) {
|
if (!note.isJavaScript() || note.getScriptEnv() !== 'backend' || !note.isContentAvailable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user