Feature/gql about webui query (#773)

* Rename "about" query to "aboutServer"

* Add "about" query for webUI
This commit is contained in:
schroda
2023-11-20 01:22:16 +01:00
committed by GitHub
parent 909bd76e08
commit 2298e71279
2 changed files with 24 additions and 3 deletions
@@ -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<WebUIUpdateInfo> {
return future {
WebInterfaceManager.getAboutInfo()
}
}
fun checkForWebUIUpdate(): CompletableFuture<WebUIUpdateInfo> {
return future {
val (version, updateAvailable) = WebInterfaceManager.isUpdateAvailable()
@@ -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) {