mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-20 21:19:29 +02:00
Better GitHub release sorting in some cases (#534)
This commit is contained in:
@@ -2,8 +2,10 @@ import 'dart:convert';
|
|||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
|
import 'package:obtainium/app_sources/html.dart';
|
||||||
import 'package:obtainium/components/generated_form.dart';
|
import 'package:obtainium/components/generated_form.dart';
|
||||||
import 'package:obtainium/custom_errors.dart';
|
import 'package:obtainium/custom_errors.dart';
|
||||||
|
import 'package:obtainium/providers/apps_provider.dart';
|
||||||
import 'package:obtainium/providers/settings_provider.dart';
|
import 'package:obtainium/providers/settings_provider.dart';
|
||||||
import 'package:obtainium/providers/source_provider.dart';
|
import 'package:obtainium/providers/source_provider.dart';
|
||||||
import 'package:url_launcher/url_launcher_string.dart';
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
@@ -133,7 +135,7 @@ class GitHub extends AppSource {
|
|||||||
? DateTime.parse(rel['published_at'])
|
? DateTime.parse(rel['published_at'])
|
||||||
: null;
|
: null;
|
||||||
releases.sort((a, b) {
|
releases.sort((a, b) {
|
||||||
// See #478
|
// See #478 and #534
|
||||||
if (a == b) {
|
if (a == b) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (a == null) {
|
} else if (a == null) {
|
||||||
@@ -141,8 +143,19 @@ class GitHub extends AppSource {
|
|||||||
} else if (b == null) {
|
} else if (b == null) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return getReleaseDateFromRelease(a)!
|
var stdFormats = findStandardFormatsForVersion(a['tag_name'], true)
|
||||||
.compareTo(getReleaseDateFromRelease(b)!);
|
.intersection(findStandardFormatsForVersion(b['tag_name'], true));
|
||||||
|
if (stdFormats.isNotEmpty) {
|
||||||
|
var reg = RegExp(stdFormats.first);
|
||||||
|
var matchA = reg.firstMatch(a['tag_name']);
|
||||||
|
var matchB = reg.firstMatch(b['tag_name']);
|
||||||
|
return compareAlphaNumeric(
|
||||||
|
(a['tag_name'] as String).substring(matchA!.start, matchA.end),
|
||||||
|
(b['tag_name'] as String).substring(matchB!.start, matchB.end));
|
||||||
|
} else {
|
||||||
|
return getReleaseDateFromRelease(a)!
|
||||||
|
.compareTo(getReleaseDateFromRelease(b)!);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
releases = releases.reversed.toList();
|
releases = releases.reversed.toList();
|
||||||
|
Reference in New Issue
Block a user