Fix Graphql-WS errors and Improve Downloader Subscription (#634)

* Fix errors in graphql-ws

* Send download messages more often
This commit is contained in:
Mitchell Syer
2023-08-04 22:48:41 -04:00
committed by GitHub
parent 689847d864
commit cdce368042
2 changed files with 4 additions and 5 deletions

View File

@@ -112,7 +112,7 @@ class ApolloSubscriptionProtocolHandler(
return subscriptionHandler.executeSubscription(request, graphQLContext) return subscriptionHandler.executeSubscription(request, graphQLContext)
.map { .map {
if (it.errors?.isNotEmpty() == true) { 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 { } else {
SubscriptionOperationMessage(type = GQL_NEXT.type, id = operationMessage.id, payload = it) SubscriptionOperationMessage(type = GQL_NEXT.type, id = operationMessage.id, payload = it)
} }

View File

@@ -132,12 +132,11 @@ object DownloadManager {
} }
private fun notifyAllClients(immediate: Boolean = false) { private fun notifyAllClients(immediate: Boolean = false) {
if (immediate) {
sendStatusToAllClients()
} else {
scope.launch { scope.launch {
notifyFlow.emit(Unit) notifyFlow.emit(Unit)
} }
if (immediate) {
sendStatusToAllClients()
} }
/*if (downloadChapter != null) { TODO GRAPHQL /*if (downloadChapter != null) { TODO GRAPHQL
downloadSubscriptionSource.publish(downloadChapter) downloadSubscriptionSource.publish(downloadChapter)