From e0815c664d338244924f52d1390d5a183f8121d0 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Thu, 4 Jun 2020 14:21:58 +0200 Subject: [PATCH] FlattenedNotesFolder: Always remove the note if present In the FlattenedNotesFolder we can have a filter to only show certain notes. This is used for showing notes that match some tags. When the note is added to this virtual folder it matches the tag, but later it does not. --- lib/core/flattened_notes_folder.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/core/flattened_notes_folder.dart b/lib/core/flattened_notes_folder.dart index e6d84d1f..4db9ed12 100644 --- a/lib/core/flattened_notes_folder.dart +++ b/lib/core/flattened_notes_folder.dart @@ -71,10 +71,12 @@ class FlattenedNotesFolder with NotesFolderNotifier implements NotesFolder { } void _noteRemoved(int _, Note note) { - if (filter != null && !filter(note)) { + var i = _notes.indexWhere((n) => n.filePath == note.filePath); + assert(filter == null ? i != -1 : true); + + if (i == -1) { return; } - var i = _notes.indexWhere((n) => n.filePath == note.filePath); assert(i != -1); _notes.removeAt(i);