Feature/graphql web UI (#649)

* Add "server" to "checkForUpdate" logic names

* Use "webUIRoot" as default path for "getLocalVersion"

* Use local version as default version for "isUpdateAvailable"

* Return the version with the webUI update check

* Update WebinterfaceManager to be async

* Add query, mutation and subscription for webUI update

* Catch error and return default error value for missing local WebUI version
This commit is contained in:
schroda
2023-08-10 02:46:48 +02:00
committed by GitHub
parent 684bb1875c
commit 74ff112e7a
7 changed files with 308 additions and 61 deletions

View File

@@ -1,8 +1,12 @@
package suwayomi.tachidesk.graphql.queries
import suwayomi.tachidesk.global.impl.AppUpdate
import suwayomi.tachidesk.graphql.types.WebUIUpdateInfo
import suwayomi.tachidesk.graphql.types.WebUIUpdateStatus
import suwayomi.tachidesk.server.BuildConfig
import suwayomi.tachidesk.server.JavalinSetup.future
import suwayomi.tachidesk.server.serverConfig
import suwayomi.tachidesk.server.util.WebInterfaceManager
import java.util.concurrent.CompletableFuture
class InfoQuery {
@@ -28,17 +32,17 @@ class InfoQuery {
)
}
data class CheckForUpdatesPayload(
data class CheckForServerUpdatesPayload(
/** [channel] mirrors [suwayomi.tachidesk.server.BuildConfig.BUILD_TYPE] */
val channel: String,
val tag: String,
val url: String
)
fun checkForUpdates(): CompletableFuture<List<CheckForUpdatesPayload>> {
fun checkForServerUpdates(): CompletableFuture<List<CheckForServerUpdatesPayload>> {
return future {
AppUpdate.checkUpdate().map {
CheckForUpdatesPayload(
CheckForServerUpdatesPayload(
channel = it.channel,
tag = it.tag,
url = it.url
@@ -46,4 +50,19 @@ class InfoQuery {
}
}
}
fun checkForWebUIUpdate(): CompletableFuture<WebUIUpdateInfo> {
return future {
val (version, updateAvailable) = WebInterfaceManager.isUpdateAvailable()
WebUIUpdateInfo(
channel = serverConfig.webUIChannel,
tag = version,
updateAvailable
)
}
}
fun getWebUIUpdateStatus(): WebUIUpdateStatus {
return WebInterfaceManager.status.value
}
}