Fix countdown festival list not sorted after date advancement (#138)

* Initial plan

* Fix: Sort countdown festivals by updated timestamps

Co-authored-by: xkeyC <39891083+xkeyC@users.noreply.github.com>

* fix: Api

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: xkeyC <39891083+xkeyC@users.noreply.github.com>
Co-authored-by: xkeyC <3334969096@qq.com>
This commit is contained in:
Copilot
2025-11-08 15:22:19 +08:00
committed by GitHub
parent 95f1cc6481
commit e212928f57
2 changed files with 21 additions and 22 deletions

View File

@@ -251,7 +251,7 @@ class HomeUIModel extends _$HomeUIModel {
List<CountdownFestivalItemData> _fixFestivalCountdownListDateTime(List<CountdownFestivalItemData> list) {
final now = DateTime.now();
return list.map((item) {
final fixedList = list.map((item) {
if (item.time == null) return item;
final itemDateTime = DateTime.fromMillisecondsSinceEpoch(item.time!);
final itemDatePlusSeven = itemDateTime.add(const Duration(days: 7));
@@ -270,6 +270,16 @@ class HomeUIModel extends _$HomeUIModel {
return item;
}).toList();
// Sort by time (ascending order - nearest festival first)
fixedList.sort((a, b) {
if (a.time == null && b.time == null) return 0;
if (a.time == null) return 1;
if (b.time == null) return -1;
return a.time!.compareTo(b.time!);
});
return fixedList;
}
Future<void> _updateSCServerStatus() async {