Improve sorting non-file items

This commit is contained in:
Ming Ming 2021-07-09 03:23:43 +08:00
parent 1a5fc2bbe2
commit a07fb0d9a4

View file

@ -134,10 +134,17 @@ class AlbumTimeSortProvider extends AlbumReversibleSortProvider {
prevFileTime = e.file.bestDateTime; prevFileTime = e.file.bestDateTime;
} }
// for non file items, use the sibling file's time // for non file items, use the sibling file's time
return Tuple2( return Tuple2(prevFileTime, e);
prevFileTime ?? DateTime.fromMillisecondsSinceEpoch(0), e);
}) })
.stableSorted((x, y) { .stableSorted((x, y) {
if (x.item1 == null && y.item1 == null) {
return 0;
}
else if (x.item1 == null) {
return -1;
} else if (y.item1 == null) {
return 1;
}
if (isAscending) { if (isAscending) {
return x.item1.compareTo(y.item1); return x.item1.compareTo(y.item1);
} else { } else {