From 90b682a38f4cc0cd3152b11757d9bdc2e7606db0 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Thu, 2 Oct 2025 17:48:06 -0400 Subject: [PATCH] Avoid sending close to subs that are already closed. --- .../quartz/nip01Core/relay/client/NostrClient.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/NostrClient.kt b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/NostrClient.kt index a636415da..d6848e72f 100644 --- a/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/NostrClient.kt +++ b/quartz/src/commonMain/kotlin/com/vitorpamplona/quartz/nip01Core/relay/client/NostrClient.kt @@ -231,7 +231,10 @@ class NostrClient( if (newFilters.isNullOrEmpty()) { // some relays are not in this sub anymore. Stop their subscriptions - relayPool.close(relay, subId) + if (!oldFilters.isNullOrEmpty()) { + // only update if the old filters are not already closed. + relayPool.close(relay, subId) + } } else if (oldFilters.isNullOrEmpty()) { // new relays were added. Start a new sub in them relayPool.sendRequest(relay, subId, newFilters) @@ -267,7 +270,10 @@ class NostrClient( if (newFilters.isNullOrEmpty()) { // some relays are not in this sub anymore. Stop their subscriptions - relayPool.close(relay, subId) + if (!oldFilters.isNullOrEmpty()) { + // only update if the old filters are not already closed. + relayPool.close(relay, subId) + } } else if (oldFilters.isNullOrEmpty()) { // new relays were added. Start a new sub in them relayPool.sendCount(relay, subId, newFilters)