diff --git a/damus.xcodeproj/project.pbxproj b/damus.xcodeproj/project.pbxproj index 461a7e6..e5bc41a 100644 --- a/damus.xcodeproj/project.pbxproj +++ b/damus.xcodeproj/project.pbxproj @@ -876,7 +876,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = damus/damus.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"damus/Preview Content\""; DEVELOPMENT_TEAM = XK7H4JAB3D; ENABLE_PREVIEWS = YES; @@ -896,7 +896,7 @@ "$(inherited)", "$(PROJECT_DIR)", ); - MARKETING_VERSION = 0.1.4; + MARKETING_VERSION = 0.1.5; PRODUCT_BUNDLE_IDENTIFIER = com.jb55.damus2; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -915,7 +915,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = damus/damus.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"damus/Preview Content\""; DEVELOPMENT_TEAM = XK7H4JAB3D; ENABLE_PREVIEWS = YES; @@ -935,7 +935,7 @@ "$(inherited)", "$(PROJECT_DIR)", ); - MARKETING_VERSION = 0.1.4; + MARKETING_VERSION = 0.1.5; PRODUCT_BUNDLE_IDENTIFIER = com.jb55.damus2; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/damus/Nostr/RelayConnection.swift b/damus/Nostr/RelayConnection.swift index 36ecb7a..eb85057 100644 --- a/damus/Nostr/RelayConnection.swift +++ b/damus/Nostr/RelayConnection.swift @@ -35,12 +35,12 @@ class RelayConnection: WebSocketDelegate { self.disconnect() } else { // we're already disconnected, so just connect - self.connect() + self.connect(force: true) } } - func connect(){ - if self.isConnected || self.isConnecting { + func connect(force: Bool = false){ + if !force && (self.isConnected || self.isConnecting) { return } diff --git a/damus/Nostr/RelayPool.swift b/damus/Nostr/RelayPool.swift index f2ebb0b..4ef2445 100644 --- a/damus/Nostr/RelayPool.swift +++ b/damus/Nostr/RelayPool.swift @@ -81,11 +81,18 @@ class RelayPool { func connect_to_disconnected() { for relay in relays { let c = relay.connection - if relay.is_broken || c.isReconnecting || c.isConnecting || c.isConnected { + + let is_connecting = c.isReconnecting || c.isConnecting + + if is_connecting && (Date.now.timeIntervalSince1970 - c.last_connection_attempt) > 10 { + print("stale connection detected (\(relay.descriptor.url.absoluteString)). retrying...") + relay.connection.connect(force: true) + } else if relay.is_broken || is_connecting || c.isConnected { continue + } else { + relay.connection.reconnect() } - relay.connection.reconnect() } }