fix: app crash after custom source

This commit is contained in:
Aabed Khan 2023-07-08 22:26:31 +05:45
parent 68876a4414
commit da6cf585c0
2 changed files with 17 additions and 3 deletions

View File

@ -1,6 +1,5 @@
import 'dart:convert';
import 'dart:io';
import 'package:collection/collection.dart';
import 'package:dio/dio.dart';
import 'package:dio_cache_interceptor/dio_cache_interceptor.dart';
@ -10,7 +9,6 @@ import 'package:injectable/injectable.dart';
import 'package:revanced_manager/models/patch.dart';
import 'package:revanced_manager/services/manager_api.dart';
@lazySingleton
class GithubAPI {
late Dio _dio = Dio();
@ -61,6 +59,22 @@ 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>?> getLatestManagerRelease(
String repoName,
) async {
try {
final response = await _dio.get(
'/repos/$repoName/releases',

View File

@ -345,7 +345,7 @@ class HomeViewModel extends BaseViewModel {
}
Future<Map<String, dynamic>?> getLatestManagerRelease() {
return _githubAPI.getLatestRelease(_managerAPI.defaultManagerRepo);
return _githubAPI.getLatestManagerRelease(_managerAPI.defaultManagerRepo);
}
Future<String?> getLatestPatcherReleaseTime() {