From 8164eee479bf564441af1fb6befadbb0e7c7374a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Mon, 15 Sep 2025 16:54:54 -0700 Subject: [PATCH] Return network EOSE in normal mode if device is offline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is done to prevent hang ups when the device is offline. Changelog-Added: Added the ability to load saved notes if device is offline Signed-off-by: Daniel D’Aquino --- .../NostrNetworkManager/SubscriptionManager.swift | 7 ++++++- damus/Core/Nostr/RelayPool.swift | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/damus/Core/Networking/NostrNetworkManager/SubscriptionManager.swift b/damus/Core/Networking/NostrNetworkManager/SubscriptionManager.swift index ca79def5..cbbef549 100644 --- a/damus/Core/Networking/NostrNetworkManager/SubscriptionManager.swift +++ b/damus/Core/Networking/NostrNetworkManager/SubscriptionManager.swift @@ -134,9 +134,14 @@ extension NostrNetworkManager { // This closure function issues (yields) an EOSE signal to the stream if all relevant conditions are met let yieldEOSEIfReady = { + let connectedToNetwork = self.pool.network_monitor.currentPath.status == .satisfied // In normal mode: Issuing EOSE requires EOSE from both NDB and the network, since they are all considered separate relays // In experimental local relay model mode: Issuing EOSE requires only EOSE from NDB, since that is the only relay that "matters" - let canIssueEOSE = self.experimentalLocalRelayModelSupport ? ndbEOSEIssued : ndbEOSEIssued && networkEOSEIssued + let canIssueEOSE = self.experimentalLocalRelayModelSupport ? + (ndbEOSEIssued) + : + (ndbEOSEIssued && (networkEOSEIssued || !connectedToNetwork)) + if canIssueEOSE { continuation.yield(.eose) } diff --git a/damus/Core/Nostr/RelayPool.swift b/damus/Core/Nostr/RelayPool.swift index c34a5e05..b15eece4 100644 --- a/damus/Core/Nostr/RelayPool.swift +++ b/damus/Core/Nostr/RelayPool.swift @@ -40,7 +40,7 @@ class RelayPool { var delegate: Delegate? private(set) var signal: SignalModel = SignalModel() - private let network_monitor = NWPathMonitor() + let network_monitor = NWPathMonitor() private let network_monitor_queue = DispatchQueue(label: "io.damus.network_monitor") private var last_network_status: NWPath.Status = .unsatisfied