return NoteModel.dump(note, include_content=True)
except InvalidFilenameError:
return invalid_filename_response
+ except FileExistsError:
+ return file_exists_response
except FileNotFoundError:
return file_not_found_response
localStorage.setItem(this.currentNote.filename, this.getEditorContent());
},
+ existingFilenameToast: function() {
+ this.$bvToast.toast(
+ "A note with this title already exists. Please try again with a new title.",
+ {
+ title: "Duplicate ✘",
+ variant: "danger",
+ noCloseButton: true,
+ }
+ );
+ },
+
saveNote: function() {
+ let parent = this;
let newContent = this.getEditorContent();
// New Note
filename: `${this.titleInput}.${constants.markdownExt}`,
content: newContent,
})
- .then(this.saveNoteResponseHandler);
+ .then(this.saveNoteResponseHandler)
+ .catch(function(error) {
+ if (error.response.status == 409) {
+ parent.existingFilenameToast();
+ }
+ });
}
// Modified Note
newFilename: `${this.titleInput}.${this.currentNote.ext}`,
newContent: newContent,
})
- .then(this.saveNoteResponseHandler);
+ .then(this.saveNoteResponseHandler)
+ .catch(function(error) {
+ if (error.response.status == 409) {
+ parent.existingFilenameToast();
+ }
+ });
}
// No Change