From 2e55d544f1975882708d5278bd6f9874d2a59b6f Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 26 Mar 2020 16:59:40 +0100 Subject: [PATCH] db setup fixes --- src/entities/note.js | 15 ++++++++------- src/entities/note_revision.js | 15 ++++++++------- src/public/javascripts/services/utils.js | 4 ++++ src/routes/api/notes.js | 2 +- src/services/notes.js | 2 +- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/entities/note.js b/src/entities/note.js index c110479d3..739eec983 100644 --- a/src/entities/note.js +++ b/src/entities/note.js @@ -95,15 +95,16 @@ class Note extends Entity { this.content = ""; } } - - if (this.isStringNote()) { - this.content = this.content === null - ? "" - : this.content.toString("UTF-8"); - } } - return this.content; + if (this.isStringNote()) { + return this.content === null + ? "" + : this.content.toString("UTF-8"); + } + else { + return this.content; + } } /** @returns {Promise<*>} */ diff --git a/src/entities/note_revision.js b/src/entities/note_revision.js index 02a6ffa8e..3220107f1 100644 --- a/src/entities/note_revision.js +++ b/src/entities/note_revision.js @@ -89,15 +89,16 @@ class NoteRevision extends Entity { this.content = ""; } } - - if (this.isStringNote()) { - this.content = this.content === null - ? "" - : this.content.toString("UTF-8"); - } } - return this.content; + if (this.isStringNote()) { + return this.content === null + ? "" + : this.content.toString("UTF-8"); + } + else { + return this.content; + } } /** @returns {Promise} */ diff --git a/src/public/javascripts/services/utils.js b/src/public/javascripts/services/utils.js index f76b1dcb0..c7889e6af 100644 --- a/src/public/javascripts/services/utils.js +++ b/src/public/javascripts/services/utils.js @@ -256,6 +256,10 @@ function openDialog($dialog) { } function isHtmlEmpty(html) { + if (!html) { + return true; + } + html = html.toLowerCase(); return $("
").html(html).text().trim().length === 0 diff --git a/src/routes/api/notes.js b/src/routes/api/notes.js index 2bea84ece..682d25f91 100644 --- a/src/routes/api/notes.js +++ b/src/routes/api/notes.js @@ -15,7 +15,7 @@ async function getNote(req) { } if (note.isStringNote()) { - await note.getContent(); + note.content = await note.getContent(); if (note.type === 'file') { note.content = note.content.substr(0, 10000); diff --git a/src/services/notes.js b/src/services/notes.js index 8955b7136..54fe87535 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -668,7 +668,7 @@ async function scanForLinks(note) { await note.setContent(newContent); } catch (e) { - log.error(`Could not scan for links note ${noteId}: ${e.message}`); + log.error(`Could not scan for links note ${note.noteId}: ${e.message} ${e.stack}`); } }