mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2025-05-19 23:46:55 +08:00
fix: code refactoring (#5)
This commit is contained in:
@ -1,32 +1,36 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
import 'package:github/github.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:revanced_manager/models/patched_application.dart';
|
||||
import 'package:timeago/timeago.dart';
|
||||
|
||||
@lazySingleton
|
||||
class GithubAPI {
|
||||
var github = GitHub();
|
||||
final GitHub _github = GitHub();
|
||||
|
||||
Future<String?> latestRelease(String org, repoName) async {
|
||||
Future<File?> latestRelease(String org, repoName) async {
|
||||
try {
|
||||
var latestRelease = await github.repositories.getLatestRelease(
|
||||
var latestRelease = await _github.repositories.getLatestRelease(
|
||||
RepositorySlug(org, repoName),
|
||||
);
|
||||
return latestRelease.assets
|
||||
String? url = latestRelease.assets
|
||||
?.firstWhere((asset) =>
|
||||
asset.name != null &&
|
||||
(asset.name!.endsWith('.dex') || asset.name!.endsWith('.apk')) &&
|
||||
!asset.name!.contains('-sources') &&
|
||||
!asset.name!.contains('-javadoc'))
|
||||
.browserDownloadUrl;
|
||||
if (url != null) {
|
||||
return await DefaultCacheManager().getSingleFile(url);
|
||||
}
|
||||
} on Exception {
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<String> latestCommitTime(String org, repoName) async {
|
||||
try {
|
||||
var repo = await github.repositories.getRepository(
|
||||
var repo = await _github.repositories.getRepository(
|
||||
RepositorySlug(org, repoName),
|
||||
);
|
||||
return repo.pushedAt != null
|
||||
@ -39,7 +43,7 @@ class GithubAPI {
|
||||
|
||||
Future<List<Contributor>> getContributors(String org, repoName) async {
|
||||
try {
|
||||
var contributors = github.repositories.listContributors(
|
||||
var contributors = _github.repositories.listContributors(
|
||||
RepositorySlug(org, repoName),
|
||||
);
|
||||
return contributors.toList();
|
||||
|
Reference in New Issue
Block a user