From 6d3232a25bb58500faa90982a052f0d3772cfbd3 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Wed, 11 Jul 2018 11:59:48 -0500 Subject: [PATCH] Note existence check --- app/assets/javascripts/app/controllers/editor.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/assets/javascripts/app/controllers/editor.js b/app/assets/javascripts/app/controllers/editor.js index 39250180e..22afa6a8d 100644 --- a/app/assets/javascripts/app/controllers/editor.js +++ b/app/assets/javascripts/app/controllers/editor.js @@ -238,6 +238,14 @@ angular.module('app') this.saveNote = function($event) { var note = this.note; note.dummy = false; + + // Make sure the note exists. A safety measure, as toggling between tags triggers deletes for dummy notes. + // Race conditions have been fixed, but we'll keep this here just in case. + if(!modelManager.findItem(note.uuid)) { + alert("The note you are attempting to save can not be found or has been deleted. Changes you make will not be synced. Please copy this note's text and start a new note."); + return; + } + this.save()(note, function(success){ if(success) { if(statusTimeout) $timeout.cancel(statusTimeout);