diff --git a/lib/core/git_repo.dart b/lib/core/git_repo.dart index c45f7012..0a2d8765 100644 --- a/lib/core/git_repo.dart +++ b/lib/core/git_repo.dart @@ -36,7 +36,6 @@ class GitNoteRepository { } Future _addNote(Note note, String commitMessage) async { - await note.save(); await _gitRepo.add("."); await _gitRepo.commit( message: commitMessage, diff --git a/lib/state_container.dart b/lib/state_container.dart index 7954414b..65ed19c9 100644 --- a/lib/state_container.dart +++ b/lib/state_container.dart @@ -259,11 +259,13 @@ class StateContainer with ChangeNotifier { void addNote(Note note) async { logEvent(Event.NoteAdded); + note.parent.add(note); + note.updateModified(); + await note.save(); + return _opLock.synchronized(() async { Log.d("Got addNote lock"); - note.parent.add(note); - note.updateModified(); _gitRepo.addNote(note).then((NoteRepoResult _) { _syncNotes(); appState.numChanges += 1; @@ -311,10 +313,12 @@ class StateContainer with ChangeNotifier { void updateNote(Note note) async { logEvent(Event.NoteUpdated); + note.updateModified(); + await note.save(); + return _opLock.synchronized(() async { Log.d("Got updateNote lock"); - note.updateModified(); _gitRepo.updateNote(note).then((NoteRepoResult _) { _syncNotes(); appState.numChanges += 1;