diff --git a/lib/strings.dart b/lib/strings.dart index d9f13d8..c941a79 100644 --- a/lib/strings.dart +++ b/lib/strings.dart @@ -2,6 +2,6 @@ class Strings { static const downloadURL = 'https://github.com/blopker/alic/releases/latest/download/Alic.Image.Compressor.dmg'; static const githubAPI = - 'https://api.github.com/repos/blopker/alic/tags?per_page=10'; + 'https://api.github.com/repos/blopker/alic/releases/latest'; static const repoURL = 'https://github.com/blopker/alic/'; } diff --git a/lib/update.dart b/lib/update.dart index ecb5972..bb56802 100644 --- a/lib/update.dart +++ b/lib/update.dart @@ -23,15 +23,16 @@ class Update { } Future getLatestBuildNumber() async { - final uri = Uri.parse(Strings.githubAPI); + var url = Strings.githubAPI; + final uri = Uri.parse(url); final response = await http.get(uri, headers: {"Accept": "application/vnd.github+json"}); - + // log.d('Response: ${response.body}'); if (response.statusCode == 200) { - final List decodedData = jsonDecode(response.body); - final tags = decodedData.map((e) => e['name'].toString()).toList(); - final latestBuild = tags.firstWhere((element) => element.contains('+')); + final Map decodedData = jsonDecode(response.body); + final latestBuild = decodedData['tag_name']; final buildNumber = int.parse(latestBuild.split('+').last); + log.d('Latest build: $latestBuild, build number: $buildNumber'); return Update( version: latestBuild, buildNumber: buildNumber,