Skip to content

Commit

Permalink
Feat: Proxy update check when requesting github fails
Browse files Browse the repository at this point in the history
  • Loading branch information
songbirdzz committed Apr 29, 2024
1 parent f8503b3 commit 1cdb4ee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions lib/navigation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,20 @@ void checkForUpdate(BuildContext context) async {
// This function can't be written at a higher level of the widget tree since
// some context problem...
if (_checkedForUpdate) return;
var resp = await Dio().get<Map<String, dynamic>>(
'https://api.github.com/repos/KNKPA/KNKPAnime/releases/latest');
Response resp;
try {
resp = await Dio().get<Map<String, dynamic>>(
'https://api.github.com/repos/KNKPA/KNKPAnime/releases/latest');
} catch (e) {
Modular.get<Logger>().w(e);
try {
resp = await Dio()
.get<Map<String, dynamic>>('https://api.withit.live/latest');
} catch (e) {
Modular.get<Logger>().w(e);
return;
}
}
var localVersion = (await PackageInfo.fromPlatform()).version;
Modular.get<Logger>().i(localVersion);
if (resp.data!['tag_name'] != localVersion) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.4
version: 1.0.5

environment:
sdk: '>=3.3.3 <4.0.0'
Expand Down

0 comments on commit 1cdb4ee

Please sign in to comment.