From 120888b53e39468935954eab9ab286c69989a765 Mon Sep 17 00:00:00 2001 From: azivner Date: Sun, 8 Apr 2018 08:31:19 -0400 Subject: [PATCH] fix JSON saving bug --- src/entities/note.js | 8 ++++++++ src/services/notes.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/entities/note.js b/src/entities/note.js index c11833667..2b5e9e7b7 100644 --- a/src/entities/note.js +++ b/src/entities/note.js @@ -21,6 +21,14 @@ class Note extends Entity { } } + setContent(content) { + this.content = content; + + if (this.isJson()) { + this.jsonContent = JSON.parse(this.content); + } + } + isJson() { return this.mime === "application/json"; } diff --git a/src/services/notes.js b/src/services/notes.js index eaa338df2..440a05bb0 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -198,7 +198,7 @@ async function updateNote(noteId, noteUpdates) { await saveNoteRevision(note); note.title = noteUpdates.title; - note.content = noteUpdates.content; + note.setContent(noteUpdates.content); note.isProtected = noteUpdates.isProtected; await note.save();