diff --git a/lib/core/note.dart b/lib/core/note.dart index c6f8da72..b60db201 100644 --- a/lib/core/note.dart +++ b/lib/core/note.dart @@ -18,7 +18,7 @@ enum NoteLoadState { NotExists, } -class Note with ChangeNotifier implements Comparable { +class Note with ChangeNotifier { NotesFolder parent; String _filePath; @@ -232,19 +232,4 @@ class Note with ChangeNotifier implements Comparable { String toString() { return 'Note{filePath: $_filePath, created: $created, modified: $modified, data: $_data}'; } - - @override - int compareTo(Note other) { - if (other == null) { - return -1; - } - - var dt = modified ?? created ?? fileLastModified; - var otherDt = other.modified ?? other.created ?? other.fileLastModified; - if (dt == null || otherDt == null) { - return _filePath.compareTo(other._filePath); - } - - return dt.compareTo(otherDt); - } } diff --git a/test/note_storage_test.dart b/test/note_storage_test.dart index 30d748ff..6712e2a3 100644 --- a/test/note_storage_test.dart +++ b/test/note_storage_test.dart @@ -56,8 +56,9 @@ void main() { loadedNotes.add(note); }); - loadedNotes.sort(); - notes.sort(); + var sortFn = (Note n1, Note n2) => n1.filePath.compareTo(n2.filePath); + loadedNotes.sort(sortFn); + notes.sort(sortFn); expect(loadedNotes, notes);