Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Pre-release setting is always fetched from the pre-releases tag #3

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/i18n/strings.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
"ripLibsLabel": "Remove unused library",
"ripLibsHint": "Compile only arm64-v8a architecture",
"preReleasesLabel": "Use pre-release",
"preReleasesHint": "Use the pre-release versions of patches and integrations",
"preReleasesHint": "Use the pre-release versions of patches and integrations if ahead of the stable version",
"preReleasesDialogText": "Use pre-release is for development purposes and may cause unexpected issues.",
"preReleasesDialogText2": "It may not be compatible with the current version of ReVanced Manager and may cause patching errors.\n\nDo you want to proceed anyways?",
"versionCompatibilityCheckLabel": "Version compatibility check",
Expand Down
6 changes: 6 additions & 0 deletions assets/i18n/strings_it_IT.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@
"showUpdateDialogHint": "Mostra una finestra di dialogo quando è disponibile un nuovo aggiornamento",
"universalPatchesLabel": "Mostra patch universali",
"universalPatchesHint": "Mostra tutte le app e patch universali (rallenterà la lista delle app)",
"ripLibsLabel": "Rimuovi librerie non utilizzate",
"ripLibsHint": "Compila solo l'architettura arm64-v8a",
"preReleasesLabel": "Usa versioni in anteprima",
"preReleasesHint": "Utilizza le versioni in anteprima di Patch e di Integrazioni se in anticipo rispetto alla versione stabile",
"preReleasesDialogText": "L'uso delle versioni in anteprima è a scopo di sviluppo e può causare problemi imprevisti.",
"preReleasesDialogText2": "Potrebbe non essere compatibile con la versione attuale di ReVanced Manager e potrebbe causare errori di patch.\n\nVuoi procedere comunque?",
"versionCompatibilityCheckLabel": "Controllo compatibilità versione",
"versionCompatibilityCheckHint": "Impedisci di selezionare patch che non sono compatibili con la versione dell'app selezionata",
"requireSuggestedAppVersionLabel": "Richiedi versione consigliata dell'app",
Expand Down
29 changes: 13 additions & 16 deletions lib/services/github_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,29 @@ class GithubAPI {
}

Future<Map<String, dynamic>?> getLatestReleaseWithPreReleases(String repoName) async {
/*
* Loop through all releases (including pre-releases) and return the latest
*/
try {
final Response response = await _dio.get('/repos/$repoName/releases');
final List<dynamic> releases = response.data;

if (releases.isEmpty) {
return getLatestRelease(repoName);
}
if (releases.isEmpty) return getLatestRelease(repoName);

Map<String, dynamic>? latestPreRelease;
DateTime latestPreReleaseDate = DateTime.fromMillisecondsSinceEpoch(0);
Map<String, dynamic>? latestRelease;
DateTime latestReleaseDate = DateTime.fromMillisecondsSinceEpoch(0);

for (final release in releases) {
if (release['prerelease'] == true) {
final DateTime releaseDate = DateTime.parse(release['published_at']);
if (releaseDate.isAfter(latestPreReleaseDate)) {
latestPreReleaseDate = releaseDate;
latestPreRelease = release;
}
for (final release in releases) {
final DateTime releaseDate = DateTime.parse(release['published_at']);
if (releaseDate.isAfter(latestReleaseDate)) {
latestReleaseDate = releaseDate;
latestRelease = release;
}
}

if (latestPreRelease == null) {
return getLatestRelease(repoName);
}
if (latestRelease == null) return getLatestRelease(repoName);

return latestPreRelease;
return latestRelease;
} catch (e) {
if (kDebugMode) {
print(e);
Expand Down