Skip to content

Commit

Permalink
fix: app crash after custom source
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAabedKhan committed Jul 8, 2023
1 parent 68876a4 commit da6cf58
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions lib/services/github_api.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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();
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/home/home_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit da6cf58

Please sign in to comment.