From bd06d76656ba0a3f2b78044b12b5d0a6f3428645 Mon Sep 17 00:00:00 2001 From: tarsin Date: Wed, 5 Jul 2023 08:43:02 +0800 Subject: [PATCH] Cleanup code --- .../java/com/hippo/ehviewer/ui/settings/AboutScreen.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/hippo/ehviewer/ui/settings/AboutScreen.kt b/app/src/main/java/com/hippo/ehviewer/ui/settings/AboutScreen.kt index 20383391b..820641ccb 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/settings/AboutScreen.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/settings/AboutScreen.kt @@ -34,6 +34,7 @@ import org.json.JSONArray import org.json.JSONObject private const val REPO_URL = "https://github.com/Ehviewer-Overhauled/Ehviewer" +private const val API_URL = "https://api.github.com/repos/Ehviewer-Overhauled/Ehviewer" private const val RELEASE_URL = "https://github.com/Ehviewer-Overhauled/Ehviewer/releases" @Composable @@ -96,18 +97,17 @@ fun AboutScreen() { WorkPreference(title = stringResource(id = R.string.settings_about_check_for_updates)) { if (Settings.useCIUpdateChannel) { val curSha = BuildConfig.COMMIT_SHA - val ciUrl = "https://api.github.com/repos/Ehviewer-Overhauled/Ehviewer" - val branch = ehRequest(ciUrl).execute { + val branch = ehRequest(API_URL).execute { JSONObject(body.string()).getString("default_branch") } - val branchUrl = "https://api.github.com/repos/Ehviewer-Overhauled/Ehviewer/branches/$branch" + val branchUrl = "$API_URL/branches/$branch" val commitSha = ehRequest(branchUrl).execute { JSONObject(body.string()).getJSONObject("commit").getString("sha") }.take(7) if (commitSha != curSha) launchSnackBar(commitSha) } else { val curVersion = BuildConfig.VERSION_NAME - val releaseUrl = "https://api.github.com/repos/Ehviewer-Overhauled/Ehviewer/releases" + val releaseUrl = "$API_URL/releases" val latestVersion = ehRequest(releaseUrl).execute { JSONArray(body.string())[0] as JSONObject }.getString("name")