From a23ef03a5d2a192ac7fe19b917228644848fab07 Mon Sep 17 00:00:00 2001 From: Joseph Heck Date: Mon, 15 Apr 2024 11:21:39 -0700 Subject: [PATCH] remove use of userdefaults from library directly, remove unused listener config control (#29) --- .../Networking/Providers/PeerToPeerProvider.swift | 10 +++------- .../Providers/PeerToPeerProviderConfiguration.swift | 6 +----- .../Networking/Providers/UserDefaultKeys.swift | 5 ----- 3 files changed, 4 insertions(+), 17 deletions(-) delete mode 100644 Sources/AutomergeRepo/Networking/Providers/UserDefaultKeys.swift diff --git a/Sources/AutomergeRepo/Networking/Providers/PeerToPeerProvider.swift b/Sources/AutomergeRepo/Networking/Providers/PeerToPeerProvider.swift index 7e5a906..dde4186 100644 --- a/Sources/AutomergeRepo/Networking/Providers/PeerToPeerProvider.swift +++ b/Sources/AutomergeRepo/Networking/Providers/PeerToPeerProvider.swift @@ -233,13 +233,9 @@ public actor PeerToPeerProvider: NetworkProvider { self.delegate = delegate self.peerId = peerId self.peerMetadata = metadata - - // if listener = true, set up a listener... - if config.listening { - if peerName.isEmpty { - let defaultName = await PeerToPeerProviderConfiguration.defaultSharingIdentity() - setName(defaultName) - } + if peerName.isEmpty { + let defaultName = await PeerToPeerProviderConfiguration.defaultSharingIdentity() + setName(defaultName) } } diff --git a/Sources/AutomergeRepo/Networking/Providers/PeerToPeerProviderConfiguration.swift b/Sources/AutomergeRepo/Networking/Providers/PeerToPeerProviderConfiguration.swift index 7e7dceb..f257c15 100644 --- a/Sources/AutomergeRepo/Networking/Providers/PeerToPeerProviderConfiguration.swift +++ b/Sources/AutomergeRepo/Networking/Providers/PeerToPeerProviderConfiguration.swift @@ -5,18 +5,15 @@ import UIKit // for UIDevice.name access public struct PeerToPeerProviderConfiguration: Sendable { let passcode: String - let listening: Bool let reconnectOnError: Bool let autoconnect: Bool public init( passcode: String, - listening: Bool, reconnectOnError: Bool = true, autoconnect: Bool? = nil ) { self.reconnectOnError = reconnectOnError - self.listening = listening if let auto = autoconnect { self.autoconnect = auto } else { @@ -40,7 +37,6 @@ public struct PeerToPeerProviderConfiguration: Sendable { #elseif os(macOS) defaultName = Host.current().localizedName ?? "Automerge User" #endif - return UserDefaults.standard - .string(forKey: UserDefaultKeys.publicPeerName) ?? defaultName + return defaultName } } diff --git a/Sources/AutomergeRepo/Networking/Providers/UserDefaultKeys.swift b/Sources/AutomergeRepo/Networking/Providers/UserDefaultKeys.swift deleted file mode 100644 index a796f8f..0000000 --- a/Sources/AutomergeRepo/Networking/Providers/UserDefaultKeys.swift +++ /dev/null @@ -1,5 +0,0 @@ -/// A collection of User Default keys for the app. -public enum UserDefaultKeys: Sendable { - /// The key to the string that the app broadcasts to represent you when sharing and syncing Automerge Documents. - public static let publicPeerName = "sharingIdentity" -}