Skip to content

Commit

Permalink
Feature/gql about webui query (#773)
Browse files Browse the repository at this point in the history
* Rename "about" query to "aboutServer"

* Add "about" query for webUI
  • Loading branch information
schroda authored Nov 20, 2023
1 parent 909bd76 commit 2298e71
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 2298e71

Please sign in to comment.