Make AttractorServer setting nil by default
This commit is contained in:
@@ -9,10 +9,20 @@ import Foundation
|
||||
|
||||
class AttractorServer
|
||||
{
|
||||
public enum Error: Swift.Error {
|
||||
case missingEndpointURL
|
||||
}
|
||||
|
||||
static let shared = AttractorServer()
|
||||
|
||||
private var endpointURL: URL {
|
||||
get { URL(string: Settings.shared.syncServer) ?? URL(string: "http://localhost")! }
|
||||
private var endpointURL: URL? {
|
||||
get {
|
||||
if let syncServer = Settings.shared.syncServer {
|
||||
return URL(string: syncServer)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
private func getHostname() -> String {
|
||||
@@ -21,6 +31,8 @@ class AttractorServer
|
||||
}
|
||||
|
||||
public func publishTabInfo(_ tabInfos: [TabInfo]) {
|
||||
guard let endpointURL else { return }
|
||||
|
||||
let hostName = getHostname()
|
||||
let rpcURL = endpointURL.appendingPathComponent("publishTabInfo")
|
||||
var components = URLComponents(url: rpcURL, resolvingAgainstBaseURL: false)!
|
||||
@@ -44,7 +56,12 @@ class AttractorServer
|
||||
}
|
||||
}
|
||||
|
||||
public func getTabInfos(_ completion: @escaping(Result<[String: [TabInfo]], Error>) -> Void) {
|
||||
public func getTabInfos(_ completion: @escaping(Result<[String: [TabInfo]], Swift.Error>) -> Void) {
|
||||
guard let endpointURL else {
|
||||
completion(.failure(Self.Error.missingEndpointURL))
|
||||
return
|
||||
}
|
||||
|
||||
let rpcURL = endpointURL.appendingPathComponent("getTabInfos")
|
||||
let request = URLRequest(url: rpcURL)
|
||||
let myHostname = getHostname()
|
||||
|
||||
Reference in New Issue
Block a user