From 2298e7127959683c9d91d1ad4af7c5ca65bb04f7 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Mon, 20 Nov 2023 01:22:16 +0100 Subject: [PATCH] Feature/gql about webui query (#773) * Rename "about" query to "aboutServer" * Add "about" query for webUI --- .../tachidesk/graphql/queries/InfoQuery.kt | 12 +++++++++--- .../tachidesk/server/util/WebInterfaceManager.kt | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/InfoQuery.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/InfoQuery.kt index c2b7dfca..bf3e8c0e 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/InfoQuery.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/InfoQuery.kt @@ -10,7 +10,7 @@ import suwayomi.tachidesk.server.util.WebInterfaceManager import java.util.concurrent.CompletableFuture class InfoQuery { - data class AboutPayload( + data class AboutServerPayload( val name: String, val version: String, val revision: String, @@ -20,8 +20,8 @@ class InfoQuery { val discord: String, ) - fun about(): AboutPayload { - return AboutPayload( + fun aboutServer(): AboutServerPayload { + return AboutServerPayload( BuildConfig.NAME, BuildConfig.VERSION, BuildConfig.REVISION, @@ -51,6 +51,12 @@ class InfoQuery { } } + fun aboutWebUI(): CompletableFuture { + return future { + WebInterfaceManager.getAboutInfo() + } + } + fun checkForWebUIUpdate(): CompletableFuture { return future { val (version, updateAvailable) = WebInterfaceManager.isUpdateAvailable() diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt index 6d13b2fb..efcd44bf 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt @@ -167,6 +167,21 @@ object WebInterfaceManager { ) } + suspend fun getAboutInfo(): WebUIUpdateInfo { + val currentVersion = getLocalVersion() + + val failedToGetVersion = currentVersion === "r-1" + if (failedToGetVersion) { + throw Exception("Failed to get current version") + } + + return WebUIUpdateInfo( + channel = serverConfig.webUIChannel.value, + tag = currentVersion, + updateAvailable = isUpdateAvailable(currentVersion).second, + ) + } + private var serveWebUI: () -> Unit = {} fun setServeWebUI(serveWebUI: () -> Unit) {