Fix/gql about webui query same response type as webui update info (#781)

* Use a new type for the webui about info query

Using the same type for this and the webui update queries/mutations caused apollo to save it as the same data in the cache, overwriting the "about info"

* Use a new type for the webui about check query

To prevent similar issues (cc3bf5f34a8afebadd306d037db1a10088ef9334) with the "update check" and the "update progress" payloads

* Throw update check error when calling it via the query

Otherwise, the error is never raised to the frontend

* Set "ERROR" state in case the update check failed on WebUI update trigger
This commit is contained in:
schroda
2023-11-26 23:17:28 +01:00
committed by GitHub
parent d65ed6ced7
commit 94b670eb81
4 changed files with 33 additions and 10 deletions

View File

@@ -3,6 +3,7 @@ package suwayomi.tachidesk.graphql.mutations
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.withTimeout
import suwayomi.tachidesk.graphql.types.UpdateState.DOWNLOADING
import suwayomi.tachidesk.graphql.types.UpdateState.ERROR
import suwayomi.tachidesk.graphql.types.UpdateState.STOPPED
import suwayomi.tachidesk.graphql.types.WebUIUpdateInfo
import suwayomi.tachidesk.graphql.types.WebUIUpdateStatus
@@ -32,6 +33,8 @@ class InfoMutation {
val (version, updateAvailable) = WebInterfaceManager.isUpdateAvailable()
if (!updateAvailable) {
val didUpdateCheckFail = version.isEmpty()
return@withTimeout WebUIUpdatePayload(
input.clientMutationId,
WebUIUpdateStatus(
@@ -41,7 +44,7 @@ class InfoMutation {
tag = version,
updateAvailable,
),
state = STOPPED,
state = if (didUpdateCheckFail) ERROR else STOPPED,
progress = 0,
),
)