1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Electron: Fixed logic to save, and make sure scheduled save always happen even when changing note

This commit is contained in:
Laurent Cozic 2018-01-11 21:05:34 +01:00
parent 424443a2d8
commit 1d7f30d441
2 changed files with 4 additions and 19 deletions

View File

@ -128,13 +128,15 @@ class NoteTextComponent extends React.Component {
if (!options) options = {};
if (!('noReloadIfLocalChanges' in options)) options.noReloadIfLocalChanges = false;
await this.saveIfNeeded();
const stateNoteId = this.state.note ? this.state.note.id : null;
const noteId = props.noteId;
let loadingNewNote = stateNoteId !== noteId;
this.lastLoadedNoteId_ = noteId;
const note = noteId ? await Note.load(noteId) : null;
if (noteId !== this.lastLoadedNoteId_) return; // Race condition - current note was changed while this one was loading
if (!options.noReloadIfLocalChanges && this.isModified()) return;
if (options.noReloadIfLocalChanges && this.isModified()) return;
// If the note hasn't been changed, exit now
if (this.state.note && note) {

View File

@ -17,14 +17,9 @@ shared.saveNoteButton_press = async function(comp) {
// just save a new note by clearing the note ID.
if (note.id && !(await shared.noteExists(note.id))) delete note.id;
// reg.logger().info('Saving note: ', note);
if (!note.parent_id) {
let folder = await Folder.defaultFolder();
if (!folder) {
//Log.warn('Cannot save note without a notebook');
return;
}
if (!folder) return;
note.parent_id = folder.id;
}
@ -36,18 +31,6 @@ shared.saveNoteButton_press = async function(comp) {
titleWasAutoAssigned = true;
}
// Save only the properties that have changed
// let diff = null;
// if (!isNew) {
// diff = BaseModel.diffObjects(comp.state.lastSavedNote, note);
// diff.type_ = note.type_;
// diff.id = note.id;
// } else {
// diff = Object.assign({}, note);
// }
// const savedNote = await Note.save(diff);
let options = {};
if (!isNew) {
options.fields = BaseModel.diffObjectsFields(comp.state.lastSavedNote, note);