From d5061a2e30f20d049c8d748770e6e50d5c870697 Mon Sep 17 00:00:00 2001 From: Jon Petersson Date: Tue, 5 Sep 2023 12:18:23 +0200 Subject: [PATCH] Fix Swiftlint warnings in LocationDataSource --- .../SelectLocation/LocationDataSource.swift | 105 ++++++++++-------- 1 file changed, 59 insertions(+), 46 deletions(-) diff --git a/ios/MullvadVPN/View controllers/SelectLocation/LocationDataSource.swift b/ios/MullvadVPN/View controllers/SelectLocation/LocationDataSource.swift index 3ee5e3245250..ee5efa3d2497 100644 --- a/ios/MullvadVPN/View controllers/SelectLocation/LocationDataSource.swift +++ b/ios/MullvadVPN/View controllers/SelectLocation/LocationDataSource.swift @@ -75,14 +75,11 @@ final class LocationDataSource: UITableViewDiffableDataSource Node { + let node: Node + + switch ascendantOrSelf { + case .country: + node = Node( + type: .country, + location: ascendantOrSelf, + displayName: serverLocation.country, + showsChildren: wasShowingChildren, + isActive: true, + children: [] + ) + rootNode.addChild(node) + + case let .city(countryCode, _): + node = Node( + type: .city, + location: ascendantOrSelf, + displayName: serverLocation.city, + showsChildren: wasShowingChildren, + isActive: true, + children: [] + ) + nodeByLocation[.country(countryCode)]!.addChild(node) + + case let .hostname(countryCode, cityCode, _): + node = Node( + type: .relay, + location: ascendantOrSelf, + displayName: relay.hostname, + showsChildren: false, + isActive: relay.active, + children: [] + ) + nodeByLocation[.city(countryCode, cityCode)]!.addChild(node) + } + + return node + } + private func updateDataSnapshot( with locations: [RelayLocation], reloadExisting: Bool = false,