From cdce3680429fb5e5332c4d74346452483ae7a99f Mon Sep 17 00:00:00 2001 From: Mitchell Syer Date: Fri, 4 Aug 2023 22:48:41 -0400 Subject: [PATCH] Fix Graphql-WS errors and Improve Downloader Subscription (#634) * Fix errors in graphql-ws * Send download messages more often --- .../subscriptions/ApolloSubscriptionProtocolHandler.kt | 2 +- .../tachidesk/manga/impl/download/DownloadManager.kt | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/subscriptions/ApolloSubscriptionProtocolHandler.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/subscriptions/ApolloSubscriptionProtocolHandler.kt index c18de81e..fcccac79 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/subscriptions/ApolloSubscriptionProtocolHandler.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/subscriptions/ApolloSubscriptionProtocolHandler.kt @@ -112,7 +112,7 @@ class ApolloSubscriptionProtocolHandler( return subscriptionHandler.executeSubscription(request, graphQLContext) .map { if (it.errors?.isNotEmpty() == true) { - SubscriptionOperationMessage(type = GQL_ERROR.type, id = operationMessage.id, payload = it) + SubscriptionOperationMessage(type = GQL_ERROR.type, id = operationMessage.id, payload = it.errors) } else { SubscriptionOperationMessage(type = GQL_NEXT.type, id = operationMessage.id, payload = it) } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt index d7a9c9e5..3df9c602 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt @@ -132,12 +132,11 @@ object DownloadManager { } private fun notifyAllClients(immediate: Boolean = false) { + scope.launch { + notifyFlow.emit(Unit) + } if (immediate) { sendStatusToAllClients() - } else { - scope.launch { - notifyFlow.emit(Unit) - } } /*if (downloadChapter != null) { TODO GRAPHQL downloadSubscriptionSource.publish(downloadChapter)