mirror of
https://github.com/StarCitizenToolBox/app.git
synced 2026-02-06 15:10:20 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user