fix runOnNoteContentChange event

This commit is contained in:
zadam 2023-05-05 15:40:44 +02:00
parent 78d83b8826
commit 35338e9ec6
3 changed files with 10 additions and 10 deletions

View File

@ -9,6 +9,7 @@ const ENTITY_DELETED = "ENTITY_DELETED";
const ENTITY_CHANGE_SYNCED = "ENTITY_CHANGE_SYNCED"; const ENTITY_CHANGE_SYNCED = "ENTITY_CHANGE_SYNCED";
const ENTITY_DELETE_SYNCED = "ENTITY_DELETE_SYNCED"; const ENTITY_DELETE_SYNCED = "ENTITY_DELETE_SYNCED";
const CHILD_NOTE_CREATED = "CHILD_NOTE_CREATED"; const CHILD_NOTE_CREATED = "CHILD_NOTE_CREATED";
const NOTE_CONTENT_CHANGE = "NOTE_CONTENT_CHANGED";
const eventListeners = {}; const eventListeners = {};
@ -69,5 +70,6 @@ module.exports = {
ENTITY_DELETED, ENTITY_DELETED,
ENTITY_CHANGE_SYNCED, ENTITY_CHANGE_SYNCED,
ENTITY_DELETE_SYNCED, ENTITY_DELETE_SYNCED,
CHILD_NOTE_CREATED CHILD_NOTE_CREATED,
NOTE_CONTENT_CHANGE
}; };

View File

@ -59,9 +59,7 @@ eventService.subscribe([ eventService.ENTITY_CHANGED, eventService.ENTITY_DELETE
}); });
eventService.subscribe(eventService.ENTITY_CHANGED, ({entityName, entity}) => { eventService.subscribe(eventService.ENTITY_CHANGED, ({entityName, entity}) => {
if (entityName === 'note_contents') { // FIXME if (entityName === 'branches') {
runAttachedRelations(entity, 'runOnNoteContentChange', entity);
} else if (entityName === 'branches') {
const parentNote = becca.getNote(entity.parentNoteId); const parentNote = becca.getNote(entity.parentNoteId);
if (parentNote?.hasLabel("sorted")) { if (parentNote?.hasLabel("sorted")) {
@ -70,6 +68,10 @@ eventService.subscribe(eventService.ENTITY_CHANGED, ({entityName, entity}) => {
} }
}); });
eventService.subscribe(eventService.NOTE_CONTENT_CHANGE, ({entity}) => {
runAttachedRelations(entity, 'runOnNoteContentChange', entity);
});
eventService.subscribe(eventService.ENTITY_CREATED, ({ entityName, entity }) => { eventService.subscribe(eventService.ENTITY_CREATED, ({ entityName, entity }) => {
if (entityName === 'attributes') { if (entityName === 'attributes') {
runAttachedRelations(entity.getNote(), 'runOnAttributeCreation', entity); runAttachedRelations(entity.getNote(), 'runOnAttributeCreation', entity);

View File

@ -229,8 +229,7 @@ function createNewNote(params) {
entity: note entity: note
}); });
eventService.emit(eventService.ENTITY_CREATED, { // FIXME eventService.emit(eventService.NOTE_CONTENT_CHANGE, {
entityName: 'note_contents',
entity: note entity: note
}); });
@ -571,10 +570,7 @@ function downloadImages(noteId, content) {
asyncPostProcessContent(origNote, updatedContent); asyncPostProcessContent(origNote, updatedContent);
eventService.emit(eventService.ENTITY_CHANGED, { eventService.emit(eventService.NOTE_CONTENT_CHANGE, { entity: origNote });
entityName: 'note_contents', // FIXME
entity: origNote
});
console.log(`Fixed the image links for note '${noteId}' to the offline saved.`); console.log(`Fixed the image links for note '${noteId}' to the offline saved.`);
} }