From 6548741803683e9bfb9e1ca3a8e6369f2953e75a Mon Sep 17 00:00:00 2001 From: Pavel Anokhov Date: Fri, 22 Jun 2018 00:43:43 +0300 Subject: [PATCH] NodesEditor: Fixed node test Removed new nodes. They not available 24/7, cycle thru nodes on network fail not yet implemented. --- Adamant/AppDelegate.swift | 4 +--- Adamant/Info.plist | 2 +- .../NodeEditorViewController.swift | 24 ++++++++++++++++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Adamant/AppDelegate.swift b/Adamant/AppDelegate.swift index 8ea860eb6..734246a07 100644 --- a/Adamant/AppDelegate.swift +++ b/Adamant/AppDelegate.swift @@ -38,9 +38,7 @@ struct AdamantResources { static let nodes: [Node] = [ Node(scheme: .https, host: "endless.adamant.im", port: nil), Node(scheme: .https, host: "clown.adamant.im", port: nil), - Node(scheme: .https, host: "lake.adamant.im", port: nil), - Node(scheme: .https, host: "158.69.59.45", port: nil), - Node(scheme: .https, host: "54.36.183.233", port: nil) + Node(scheme: .https, host: "lake.adamant.im", port: nil) ] static let iosAppSupportEmail = "ios@adamant.im" diff --git a/Adamant/Info.plist b/Adamant/Info.plist index 27c849224..40f76ae09 100644 --- a/Adamant/Info.plist +++ b/Adamant/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 0.3.12 CFBundleVersion - 30 + 31 LSRequiresIPhoneOS NSCameraUsageDescription diff --git a/Adamant/Stories/NodesEditor/NodeEditorViewController.swift b/Adamant/Stories/NodesEditor/NodeEditorViewController.swift index 083238eda..6926ce244 100644 --- a/Adamant/Stories/NodesEditor/NodeEditorViewController.swift +++ b/Adamant/Stories/NodesEditor/NodeEditorViewController.swift @@ -231,7 +231,29 @@ class NodeEditorViewController: FormViewController { // MARK: - Actions extension NodeEditorViewController { func testNode(completion: ((Bool) -> Void)? = nil) { - guard let url = node?.asURL() else { + var components = URLComponents() + + // Host + if let row: TextRow = form.rowBy(tag: Rows.host.tag), let host = row.value { + components.host = host + } + + // Scheme + if let row = form.rowBy(tag: Rows.scheme.tag), let scheme = row.baseValue as? URLScheme { + components.scheme = scheme.rawValue + } else { + components.scheme = "https" + } + + // Port + if let row: IntRow = form.rowBy(tag: Rows.port.tag), let port = row.value { + components.port = port + } + + let url: URL + do { + url = try components.asURL() + } catch { testState = .failed dialogService.showWarning(withMessage: String.adamantLocalized.nodesEditor.failedToBuildURL) return