mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-09 16:52:14 +01:00
fix: Download latest integrations non-pre-release
This commit is contained in:
parent
7e0f18e3b7
commit
4a72267d41
3 changed files with 10 additions and 66 deletions
|
@ -23,39 +23,6 @@ class GithubAPI {
|
|||
|
||||
Future<Map<String, dynamic>?> getLatestRelease(
|
||||
String repoName,
|
||||
) async {
|
||||
try {
|
||||
final response = await _dio.get(
|
||||
'/repos/$repoName/releases',
|
||||
);
|
||||
return response.data[0];
|
||||
} on Exception catch (e) {
|
||||
if (kDebugMode) {
|
||||
print(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>?> getPatchesRelease(
|
||||
String repoName,
|
||||
String version,
|
||||
) async {
|
||||
try {
|
||||
final response = await _dio.get(
|
||||
'/repos/$repoName/releases/tags/$version',
|
||||
);
|
||||
return response.data;
|
||||
} on Exception catch (e) {
|
||||
if (kDebugMode) {
|
||||
print(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>?> getLatestPatchesRelease(
|
||||
String repoName,
|
||||
) async {
|
||||
try {
|
||||
final response = await _dio.get(
|
||||
|
@ -108,32 +75,7 @@ class GithubAPI {
|
|||
}
|
||||
}
|
||||
|
||||
Future<File?> getLatestReleaseFile(
|
||||
String extension,
|
||||
String repoName,
|
||||
) async {
|
||||
try {
|
||||
final Map<String, dynamic>? release = await getLatestRelease(repoName);
|
||||
if (release != null) {
|
||||
final Map<String, dynamic>? asset =
|
||||
(release['assets'] as List<dynamic>).firstWhereOrNull(
|
||||
(asset) => (asset['name'] as String).endsWith(extension),
|
||||
);
|
||||
if (asset != null) {
|
||||
return await _downloadManager.getSingleFile(
|
||||
asset['browser_download_url'],
|
||||
);
|
||||
}
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
if (kDebugMode) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<File?> getPatchesReleaseFile(
|
||||
Future<File?> getReleaseFile(
|
||||
String extension,
|
||||
String repoName,
|
||||
String version,
|
||||
|
@ -145,8 +87,10 @@ class GithubAPI {
|
|||
url,
|
||||
);
|
||||
}
|
||||
final Map<String, dynamic>? release =
|
||||
await getPatchesRelease(repoName, version);
|
||||
final response = await _dio.get(
|
||||
'/repos/$repoName/releases/tags/$version',
|
||||
);
|
||||
final Map<String, dynamic>? release = response.data;
|
||||
if (release != null) {
|
||||
final Map<String, dynamic>? asset =
|
||||
(release['assets'] as List<dynamic>).firstWhereOrNull(
|
||||
|
|
|
@ -422,7 +422,7 @@ class ManagerAPI {
|
|||
final String repoName = !isUsingAlternativeSources() ? defaultPatchesRepo : getPatchesRepo();
|
||||
final String currentVersion = await getCurrentPatchesVersion();
|
||||
final String url = getPatchesDownloadURL();
|
||||
return await _githubAPI.getPatchesReleaseFile(
|
||||
return await _githubAPI.getReleaseFile(
|
||||
'.jar',
|
||||
repoName,
|
||||
currentVersion,
|
||||
|
@ -441,7 +441,7 @@ class ManagerAPI {
|
|||
final String repoName = !isUsingAlternativeSources() ? defaultIntegrationsRepo : getIntegrationsRepo();
|
||||
final String currentVersion = await getCurrentIntegrationsVersion();
|
||||
final String url = getIntegrationsDownloadURL();
|
||||
return await _githubAPI.getPatchesReleaseFile(
|
||||
return await _githubAPI.getReleaseFile(
|
||||
'.apk',
|
||||
repoName,
|
||||
currentVersion,
|
||||
|
@ -470,7 +470,7 @@ class ManagerAPI {
|
|||
);
|
||||
} else {
|
||||
final release =
|
||||
await _githubAPI.getLatestPatchesRelease(getPatchesRepo());
|
||||
await _githubAPI.getLatestRelease(getPatchesRepo());
|
||||
if (release != null) {
|
||||
final DateTime timestamp =
|
||||
DateTime.parse(release['created_at'] as String);
|
||||
|
@ -519,7 +519,7 @@ class ManagerAPI {
|
|||
);
|
||||
} else {
|
||||
final release =
|
||||
await _githubAPI.getLatestPatchesRelease(getPatchesRepo());
|
||||
await _githubAPI.getLatestRelease(getPatchesRepo());
|
||||
if (release != null) {
|
||||
return release['tag_name'];
|
||||
} else {
|
||||
|
|
|
@ -480,7 +480,7 @@ class HomeViewModel extends BaseViewModel {
|
|||
}
|
||||
|
||||
Future<Map<String, dynamic>?> getLatestPatchesRelease() {
|
||||
return _githubAPI.getLatestPatchesRelease(_managerAPI.defaultPatchesRepo);
|
||||
return _githubAPI.getLatestRelease(_managerAPI.defaultPatchesRepo);
|
||||
}
|
||||
|
||||
Future<String?> getLatestPatchesReleaseTime() {
|
||||
|
|
Loading…
Reference in a new issue