mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-07 21:04:34 -05:00
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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user