mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-12 18:04:28 +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(
|
Future<Map<String, dynamic>?> getLatestRelease(
|
||||||
String repoName,
|
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 {
|
) async {
|
||||||
try {
|
try {
|
||||||
final response = await _dio.get(
|
final response = await _dio.get(
|
||||||
|
@ -108,32 +75,7 @@ class GithubAPI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<File?> getLatestReleaseFile(
|
Future<File?> getReleaseFile(
|
||||||
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(
|
|
||||||
String extension,
|
String extension,
|
||||||
String repoName,
|
String repoName,
|
||||||
String version,
|
String version,
|
||||||
|
@ -145,8 +87,10 @@ class GithubAPI {
|
||||||
url,
|
url,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final Map<String, dynamic>? release =
|
final response = await _dio.get(
|
||||||
await getPatchesRelease(repoName, version);
|
'/repos/$repoName/releases/tags/$version',
|
||||||
|
);
|
||||||
|
final Map<String, dynamic>? release = response.data;
|
||||||
if (release != null) {
|
if (release != null) {
|
||||||
final Map<String, dynamic>? asset =
|
final Map<String, dynamic>? asset =
|
||||||
(release['assets'] as List<dynamic>).firstWhereOrNull(
|
(release['assets'] as List<dynamic>).firstWhereOrNull(
|
||||||
|
|
|
@ -422,7 +422,7 @@ class ManagerAPI {
|
||||||
final String repoName = !isUsingAlternativeSources() ? defaultPatchesRepo : getPatchesRepo();
|
final String repoName = !isUsingAlternativeSources() ? defaultPatchesRepo : getPatchesRepo();
|
||||||
final String currentVersion = await getCurrentPatchesVersion();
|
final String currentVersion = await getCurrentPatchesVersion();
|
||||||
final String url = getPatchesDownloadURL();
|
final String url = getPatchesDownloadURL();
|
||||||
return await _githubAPI.getPatchesReleaseFile(
|
return await _githubAPI.getReleaseFile(
|
||||||
'.jar',
|
'.jar',
|
||||||
repoName,
|
repoName,
|
||||||
currentVersion,
|
currentVersion,
|
||||||
|
@ -441,7 +441,7 @@ class ManagerAPI {
|
||||||
final String repoName = !isUsingAlternativeSources() ? defaultIntegrationsRepo : getIntegrationsRepo();
|
final String repoName = !isUsingAlternativeSources() ? defaultIntegrationsRepo : getIntegrationsRepo();
|
||||||
final String currentVersion = await getCurrentIntegrationsVersion();
|
final String currentVersion = await getCurrentIntegrationsVersion();
|
||||||
final String url = getIntegrationsDownloadURL();
|
final String url = getIntegrationsDownloadURL();
|
||||||
return await _githubAPI.getPatchesReleaseFile(
|
return await _githubAPI.getReleaseFile(
|
||||||
'.apk',
|
'.apk',
|
||||||
repoName,
|
repoName,
|
||||||
currentVersion,
|
currentVersion,
|
||||||
|
@ -470,7 +470,7 @@ class ManagerAPI {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
final release =
|
final release =
|
||||||
await _githubAPI.getLatestPatchesRelease(getPatchesRepo());
|
await _githubAPI.getLatestRelease(getPatchesRepo());
|
||||||
if (release != null) {
|
if (release != null) {
|
||||||
final DateTime timestamp =
|
final DateTime timestamp =
|
||||||
DateTime.parse(release['created_at'] as String);
|
DateTime.parse(release['created_at'] as String);
|
||||||
|
@ -519,7 +519,7 @@ class ManagerAPI {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
final release =
|
final release =
|
||||||
await _githubAPI.getLatestPatchesRelease(getPatchesRepo());
|
await _githubAPI.getLatestRelease(getPatchesRepo());
|
||||||
if (release != null) {
|
if (release != null) {
|
||||||
return release['tag_name'];
|
return release['tag_name'];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -480,7 +480,7 @@ class HomeViewModel extends BaseViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, dynamic>?> getLatestPatchesRelease() {
|
Future<Map<String, dynamic>?> getLatestPatchesRelease() {
|
||||||
return _githubAPI.getLatestPatchesRelease(_managerAPI.defaultPatchesRepo);
|
return _githubAPI.getLatestRelease(_managerAPI.defaultPatchesRepo);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> getLatestPatchesReleaseTime() {
|
Future<String?> getLatestPatchesReleaseTime() {
|
||||||
|
|
Loading…
Reference in a new issue