Skip to content

Build your personal knowledge base with Trilium Notes

db setup fixes

zadam2e55d544f197
diff --git a/src/entities/note.js b/src/entities/note.js
index c110479d30..739eec9839 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 02a6ffa8e8..3220107f19 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 f76b1dcb0b..c7889e6afb 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 $("<div>").html(html).text().trim().length === 0
diff --git a/src/routes/api/notes.js b/src/routes/api/notes.js
index 2bea84ece3..682d25f91e 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 8955b7136b..54fe87535d 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}`);
}
}