mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 03:19:11 +08:00
Note class should not be sortable
There are various different methods of sorting an note.
This commit is contained in:
@ -18,7 +18,7 @@ enum NoteLoadState {
|
||||
NotExists,
|
||||
}
|
||||
|
||||
class Note with ChangeNotifier implements Comparable<Note> {
|
||||
class Note with ChangeNotifier {
|
||||
NotesFolder parent;
|
||||
String _filePath;
|
||||
|
||||
@ -232,19 +232,4 @@ class Note with ChangeNotifier implements Comparable<Note> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user