Skip to content

Commit 9b84a67

Browse files
More plumbo
1 parent 7a44d86 commit 9b84a67

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

Kickstarter-iOS/Features/PledgeShippingLocation/PledgeShippingLocationViewController.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ final class PledgeShippingLocationViewController: UIViewController {
135135
.observeForUI()
136136
.observeValues { [weak self] project, shippingRules, location in
137137
self?.presentShippingRules(
138-
project, shippingRules: shippingRules, selectedLocation: location
138+
project: project, shippingRules: shippingRules, selectedLocation: location
139139
)
140140
}
141141

@@ -169,10 +169,22 @@ final class PledgeShippingLocationViewController: UIViewController {
169169
// MARK: - Functions
170170

171171
private func presentShippingRules(
172-
_: Project, shippingRules: [ShippingRule], selectedLocation: Location
172+
project: Project, shippingRules _: [ShippingRule], selectedLocation: Location
173173
) {
174+
let locations: [Location] = project.rewards.map { $0.shippingRulesExpanded }
175+
.map { rules in
176+
rules?.map { $0.location }
177+
}
178+
.reduce([]) { allLocations, locations in
179+
guard let locations = locations else {
180+
return allLocations
181+
}
182+
183+
return allLocations + locations
184+
}
185+
174186
let viewController = ShippingLocationsViewController(
175-
withLocations: shippingRules.map { $0.location },
187+
withLocations: locations,
176188
selectedLocation: selectedLocation
177189
) { location in
178190

0 commit comments

Comments
 (0)