From 5d619ca036cdd742ca3d5f26c212c66ce79d3c8c Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Thu, 9 May 2024 15:18:44 +0600 Subject: [PATCH] chore: fix some errors parsing nightly version info --- lib/components/root/update_dialog.dart | 4 ++-- lib/utils/service_utils.dart | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/components/root/update_dialog.dart b/lib/components/root/update_dialog.dart index f9621d6a..e15903c6 100644 --- a/lib/components/root/update_dialog.dart +++ b/lib/components/root/update_dialog.dart @@ -31,10 +31,10 @@ class RootAppUpdateDialog extends StatelessWidget { children: [ Text( nightlyBuildNum != null - ? "Spotube Nightly $nightlyBuildNum has been releases" + ? "Spotube Nightly $nightlyBuildNum has been released" : "Spotube v$version has been released", ), - if (nightlyBuildNum != null) + if (nightlyBuildNum == null) Row( mainAxisAlignment: MainAxisAlignment.center, children: [ diff --git a/lib/utils/service_utils.dart b/lib/utils/service_utils.dart index d3158948..ec3bb0cb 100644 --- a/lib/utils/service_utils.dart +++ b/lib/utils/service_utils.dart @@ -340,16 +340,12 @@ abstract class ServiceUtils { if (Env.releaseChannel == ReleaseChannel.nightly) { final value = await http.get( Uri.parse( - "https://api.github.com/repos/KRTirtho/spotube/releases/tags/nightly", + "https://api.github.com/repos/KRTirtho/spotube/actions/workflows/spotube-release-binary.yml/runs?status=success&per_page=1", ), ); - final body = jsonDecode(value.body)["body"] as String; - - final buildNum = int.tryParse( - RegExp(r'Build Number: (\d+)').firstMatch(body)?.group(1) ?? '0', - ) ?? - 0; + final buildNum = + jsonDecode(value.body)["workflow_runs"][0]["run_number"] as int; if (buildNum <= int.parse(packageInfo.buildNumber) || !context.mounted) { return;