From 7e4d70259fcf026aceaf1f8756e20be807c3a00a Mon Sep 17 00:00:00 2001 From: azivner Date: Thu, 26 Jul 2018 09:08:51 +0200 Subject: [PATCH] soft-deleting note will delete its content and all the revisions content, fixes #132 --- .../0105__delete_content_from_soft_deleted_notes.sql | 2 ++ src/services/app_info.js | 2 +- src/services/notes.js | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrations/0105__delete_content_from_soft_deleted_notes.sql diff --git a/db/migrations/0105__delete_content_from_soft_deleted_notes.sql b/db/migrations/0105__delete_content_from_soft_deleted_notes.sql new file mode 100644 index 000000000..d594841ee --- /dev/null +++ b/db/migrations/0105__delete_content_from_soft_deleted_notes.sql @@ -0,0 +1,2 @@ +UPDATE notes SET content = '' WHERE isDeleted = 1; +UPDATE note_revisions SET content = '' WHERE (SELECT isDeleted FROM notes WHERE noteId = note_revisions.noteId) = 1; \ No newline at end of file diff --git a/src/services/app_info.js b/src/services/app_info.js index e7835d71f..99c63a630 100644 --- a/src/services/app_info.js +++ b/src/services/app_info.js @@ -3,7 +3,7 @@ const build = require('./build'); const packageJson = require('../../package'); -const APP_DB_VERSION = 104; +const APP_DB_VERSION = 105; const SYNC_VERSION = 1; module.exports = { diff --git a/src/services/notes.js b/src/services/notes.js index e4fb74557..ed5be7bc8 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -223,8 +223,14 @@ async function deleteNote(branch) { if (notDeletedBranches.length === 0) { note.isDeleted = true; + note.content = ''; await note.save(); + for (const noteRevision of await note.getRevisions()) { + noteRevision.content = ''; + await noteRevision.save(); + } + for (const childBranch of await note.getChildBranches()) { await deleteNote(childBranch); }