From 9cdcbb3125dfb6a5cc7cdddf3fca48d47972b8ec Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 5 May 2023 15:42:53 +0200 Subject: [PATCH] fix runOnNoteContentChange event --- src/becca/entities/bnote.js | 3 +++ src/services/notes.js | 6 ------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/becca/entities/bnote.js b/src/becca/entities/bnote.js index c20db6f1c..60ee4dd3f 100644 --- a/src/becca/entities/bnote.js +++ b/src/becca/entities/bnote.js @@ -12,6 +12,7 @@ const TaskContext = require("../../services/task_context"); const dayjs = require("dayjs"); const utc = require('dayjs/plugin/utc'); const NotFoundError = require("../../errors/not_found_error.js"); +const eventService = require("../../services/events.js"); dayjs.extend(utc); const LABEL = 'label'; @@ -246,6 +247,8 @@ class BNote extends AbstractBeccaEntity { */ setContent(content, opts) { this._setContent(content, opts); + + eventService.emit(eventService.NOTE_CONTENT_CHANGE, { entity: this }); } setJsonContent(content) { diff --git a/src/services/notes.js b/src/services/notes.js index c5f0fbb70..d0e1b2ac6 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -229,10 +229,6 @@ function createNewNote(params) { entity: note }); - eventService.emit(eventService.NOTE_CONTENT_CHANGE, { - entity: note - }); - eventService.emit(eventService.ENTITY_CREATED, { entityName: 'branches', entity: branch @@ -570,8 +566,6 @@ function downloadImages(noteId, content) { asyncPostProcessContent(origNote, updatedContent); - eventService.emit(eventService.NOTE_CONTENT_CHANGE, { entity: origNote }); - console.log(`Fixed the image links for note '${noteId}' to the offline saved.`); } });