fix: app listing on Home View

This commit is contained in:
Alberto Ponces
2022-08-17 17:07:00 +01:00
parent d351b86f41
commit 750f035104
13 changed files with 127 additions and 50 deletions

View File

@ -1,5 +1,6 @@
import 'package:github/github.dart';
import 'package:injectable/injectable.dart';
import 'package:revanced_manager/models/patched_application.dart';
import 'package:timeago/timeago.dart';
@lazySingleton
@ -7,12 +8,11 @@ class GithubAPI {
var github = GitHub();
Future<String?> latestRelease(String org, repoName) async {
String? dlurl = '';
try {
var latestRelease = await github.repositories.getLatestRelease(
RepositorySlug(org, repoName),
);
dlurl = latestRelease.assets
return latestRelease.assets
?.firstWhere((asset) =>
asset.name != null &&
(asset.name!.endsWith('.dex') || asset.name!.endsWith('.apk')) &&
@ -20,24 +20,21 @@ class GithubAPI {
!asset.name!.contains('-javadoc'))
.browserDownloadUrl;
} on Exception {
dlurl = '';
return '';
}
return dlurl;
}
Future<String> latestCommitTime(String org, repoName) async {
String pushedAt = '';
try {
var repo = await github.repositories.getRepository(
RepositorySlug(org, repoName),
);
pushedAt = repo.pushedAt != null
return repo.pushedAt != null
? format(repo.pushedAt!, locale: 'en_short')
: '';
} on Exception {
pushedAt = '';
return '';
}
return pushedAt;
}
Future<List<Contributor>> getContributors(String org, repoName) async {
@ -50,4 +47,15 @@ class GithubAPI {
return List.empty();
}
}
Future<bool> hasUpdates(PatchedApplication app, String org, repoName) async {
// TODO: get status based on last update time on the folder of this app?
return true;
}
Future<String> getChangelog(
PatchedApplication app, String org, repoName) async {
// TODO: get changelog based on last commits on the folder of this app?
return 'fix: incorrect fingerprint version';
}
}