From 87393ac588f8a22b0a85e696446e39e98977054e Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Thu, 14 May 2020 16:59:03 +0200 Subject: [PATCH] NoteCache: Avoid duplicates This should ideally never happen, but it seems to be occasionally happening for some reason. --- lib/core/notes_cache.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/core/notes_cache.dart b/lib/core/notes_cache.dart index ec3b7039..397ff559 100644 --- a/lib/core/notes_cache.dart +++ b/lib/core/notes_cache.dart @@ -85,7 +85,9 @@ class NotesCache { var heap = HeapPriorityQueue(reversedFn); for (var note in allNotes) { - heap.add(note); + if (!heap.contains(note)) { + heap.add(note); + } if (heap.length > CACHE_SIZE) { heap.removeFirst(); }