1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-12 22:57:38 +02:00

All: Use mutex when saving model to avoid race conditions when decrypting and syncing at the same time

This commit is contained in:
Laurent Cozic
2018-02-07 19:02:07 +00:00
parent 80801cedf0
commit 69fd32e7c6
8 changed files with 90 additions and 19 deletions

View File

@ -381,26 +381,26 @@ class Note extends BaseItem {
return this.save(newNote);
}
static save(o, options = null) {
static async save(o, options = null) {
let isNew = this.isNew(o, options);
if (isNew && !o.source) o.source = Setting.value('appName');
if (isNew && !o.source_application) o.source_application = Setting.value('appId');
return super.save(o, options).then((note) => {
this.dispatch({
type: 'NOTE_UPDATE_ONE',
note: note,
});
const note = await super.save(o, options);
if ('todo_due' in o || 'todo_completed' in o || 'is_todo' in o || 'is_conflict' in o) {
this.dispatch({
type: 'EVENT_NOTE_ALARM_FIELD_CHANGE',
id: note.id,
});
}
return note;
this.dispatch({
type: 'NOTE_UPDATE_ONE',
note: note,
});
if ('todo_due' in o || 'todo_completed' in o || 'is_todo' in o || 'is_conflict' in o) {
this.dispatch({
type: 'EVENT_NOTE_ALARM_FIELD_CHANGE',
id: note.id,
});
}
return note;
}
static async delete(id, options = null) {