Skip to content

Commit d341d7c

Browse files
authored
Merge pull request #2674 from tnswo561412/main
Fixes the bug where apps without release date info (like F-Droid apps) would appear in random positions when sorting by release date.
2 parents a2b6b00 + 38216a5 commit d341d7c

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

lib/pages/apps.dart

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,23 @@ class AppsPageState extends State<AppsPage> {
276276
);
277277
} else if (settingsProvider.sortColumn ==
278278
SortColumnSettings.releaseDate) {
279-
result =
280-
(a.app.releaseDate)?.compareTo(
281-
b.app.releaseDate ?? DateTime.fromMicrosecondsSinceEpoch(0),
282-
) ??
283-
0;
279+
// Handle null dates: apps with unknown release dates are grouped at the end
280+
final aDate = a.app.releaseDate;
281+
final bDate = b.app.releaseDate;
282+
if (aDate == null && bDate == null) {
283+
// Both null: sort by name for consistency
284+
result = ((a.name + a.author).toLowerCase()).compareTo(
285+
(b.name + b.author).toLowerCase(),
286+
);
287+
} else if (aDate == null) {
288+
// a has no date, push to end (ascending) or beginning (will be reversed for descending)
289+
result = 1;
290+
} else if (bDate == null) {
291+
// b has no date, push to end
292+
result = -1;
293+
} else {
294+
result = aDate.compareTo(bDate);
295+
}
284296
}
285297
return result;
286298
});

lib/providers/apps_provider.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,8 @@ class AppsProvider with ChangeNotifier {
12421242
}
12431243
if (sayInstalled) {
12441244
installedIds.add(id);
1245+
// Dismiss the update notification since the app was successfully installed
1246+
notificationsProvider?.cancel(UpdateNotification([]).id);
12451247
}
12461248
} finally {
12471249
apps[id]?.downloadProgress = null;

0 commit comments

Comments
 (0)