From 475315785c20b4cb030abeaa3aa5238c2ecd9c27 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Fri, 15 Feb 2019 20:12:13 +0100 Subject: [PATCH] Delete Note: Do not sync untill the snackbar has gone Otherwise we would have already pushed that change to the server, and undo-ing it will be impossible. --- lib/state_container.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/state_container.dart b/lib/state_container.dart index f9d77363..62f1ae06 100644 --- a/lib/state_container.dart +++ b/lib/state_container.dart @@ -166,7 +166,12 @@ class StateContainerState extends State { void removeNote(Note note) { setState(() { appState.notes.remove(note); - noteRepo.removeNote(note).then((NoteRepoResult _) { + noteRepo.removeNote(note).then((NoteRepoResult _) async { + // FIXME: Is there a way of figuring this amount dynamically? + // The '4 seconds' is taken from snack_bar.dart -> _kSnackBarDisplayDuration + // We wait an aritfical amount of time, so that the user has a change to undo + // their delete operation, and that commit is not synced with the server, till then. + await Future.delayed(const Duration(seconds: 4)); _syncNotes(); }); });