Skip to content

Commit 2ddf05f

Browse files
committed
Merge branch 'develop' of github.com:woocommerce/woocommerce-ios into feature/177-dashboard-mark6
* 'develop' of github.com:woocommerce/woocommerce-ios: Code review changes: `public` declaration not needed for cell variables, `guard` instead of `if let` Updating Authenticator to Mark 1.0.6 Missed a whitespace Support empty addresses `pod update` Code review changes: make it swift-y Order List: Improve custom payment labels AppDelegate: Nukes unneeded self OrderStoreTests: Fixing Typo SettingsViewController: Simplifies downcasting MockupNetwork: Nukes extra dot AlamofireNetwork: Nukes extra space Order: Simplifies parsing # Conflicts: # Podfile.lock
2 parents 76e0563 + c5e97e8 commit 2ddf05f

File tree

17 files changed

+71
-87
lines changed

17 files changed

+71
-87
lines changed

Networking/Networking/Model/Order.swift

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,8 @@ public struct Order: Decodable {
117117

118118
let items = try container.decode([OrderItem].self, forKey: .items)
119119

120-
var shippingAddress: Address? = nil
121-
do {
122-
shippingAddress = try container.decodeIfPresent(Address.self, forKey: .shippingAddress)
123-
} catch {
124-
// no-op
125-
}
126-
127-
var billingAddress: Address? = nil
128-
do {
129-
billingAddress = try container.decode(Address.self, forKey: .billingAddress)
130-
} catch {
131-
billingAddress = Address(firstName: "", lastName: "", company: "", address1: "", address2: "", city: "", state: "", postcode: "", country: "", phone: "", email: "")
132-
}
120+
let shippingAddress = try? container.decode(Address.self, forKey: .shippingAddress)
121+
let billingAddress = try? container.decode(Address.self, forKey: .billingAddress)
133122

134123
let coupons = try container.decode([OrderCouponLine].self, forKey: .couponLines)
135124

Networking/Networking/Model/OrderStatus.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ extension OrderStatus: RawRepresentable {
6464
extension OrderStatus: CustomStringConvertible {
6565

6666
/// Returns a string describing the current OrderStatus Instance
67+
/// Custom doesn't return a localized string because the payload arrives at runtime, not buildtime.
6768
///
6869
public var description: String {
6970
switch self {
@@ -74,7 +75,10 @@ extension OrderStatus: CustomStringConvertible {
7475
case .cancelled: return NSLocalizedString("Canceled", comment: "Cancelled Order Status")
7576
case .completed: return NSLocalizedString("Completed", comment: "Completed Order Status")
7677
case .refunded: return NSLocalizedString("Refunded", comment: "Refunded Order Status")
77-
case .custom(let payload): return NSLocalizedString("\(payload)", comment: "Custom Order Status")
78+
case .custom(let payload):
79+
return payload
80+
.replacingOccurrences(of: "-", with: " ")
81+
.capitalized
7882
}
7983
}
8084
}

Networking/Networking/Network/AlamofireNetwork.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class AlamofireNetwork: Network {
6161
///
6262
private extension Alamofire.DataResponse {
6363

64-
/// Returns `NetworkError.notFound` whenever the Request failed with a 404 StatusCode. This may be used by upper layers,
64+
/// Returns `NetworkError.notFound` whenever the Request failed with a 404 StatusCode. This may be used by upper layers,
6565
/// to determine if an object should be deleted (for instance!).
6666
///
6767
/// In any other case, this property will actually return the regular `DataResponse.error` result.

Networking/Networking/Network/MockupNetwork.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ extension MockupNetwork {
8888
responseMap[requestUrlSuffix] = filename
8989
}
9090

91-
/// We'll return the specified Error, whenever a request matches the specified Suffix Criteria!.
91+
/// We'll return the specified Error, whenever a request matches the specified Suffix Criteria!
9292
///
9393
func simulateError(requestUrlSuffix: String, error: Error) {
9494
errorMap[requestUrlSuffix] = error

Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ target 'WooCommerce' do
1818
#
1919
pod 'Automattic-Tracks-iOS', :git => 'https://github.com/Automattic/Automattic-Tracks-iOS.git', :tag => '0.2.3'
2020
pod 'Gridicons', '0.15'
21-
pod 'WordPressAuthenticator', '1.0.5'
21+
pod 'WordPressAuthenticator', '1.0.6'
2222
pod 'WordPressShared', '1.0.8'
2323

2424

Podfile.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ PODS:
1616
- CocoaLumberjack/Default
1717
- CocoaLumberjack/Swift (3.4.2):
1818
- CocoaLumberjack/Default
19-
- Crashlytics (3.10.5):
20-
- Fabric (~> 1.7.9)
21-
- Fabric (1.7.9)
19+
- Crashlytics (3.10.7):
20+
- Fabric (~> 1.7.11)
21+
- Fabric (1.7.11)
2222
- FormatterKit/Resources (1.8.2)
2323
- FormatterKit/TimeIntervalFormatter (1.8.2):
2424
- FormatterKit/Resources
@@ -41,7 +41,7 @@ PODS:
4141
- Reachability (3.2)
4242
- SVProgressHUD (2.2.5)
4343
- UIDeviceIdentifier (0.5.0)
44-
- WordPressAuthenticator (1.0.5):
44+
- WordPressAuthenticator (1.0.6):
4545
- 1PasswordExtension (= 1.8.5)
4646
- Alamofire (= 4.7.2)
4747
- CocoaLumberjack (= 3.4.2)
@@ -77,7 +77,7 @@ DEPENDENCIES:
7777
- Crashlytics (~> 3.10)
7878
- Gridicons (= 0.15)
7979
- KeychainAccess (~> 3.1)
80-
- WordPressAuthenticator (= 1.0.5)
80+
- WordPressAuthenticator (= 1.0.6)
8181
- WordPressShared (= 1.0.8)
8282
- XLPagerTabStrip (~> 8.0)
8383

@@ -123,8 +123,8 @@ SPEC CHECKSUMS:
123123
Automattic-Tracks-iOS: d8c6c6c1351b1905a73e45f431b15598d71963b5
124124
Charts: 90a4d61da0f6e06684c591e3bcab11940fe61736
125125
CocoaLumberjack: db7cc9e464771f12054c22ff6947c5a58d43a0fd
126-
Crashlytics: 7f2e38d302d9da96475b3d64d86fb29e31a542b7
127-
Fabric: a2917d3895e4c1569b9c3170de7320ea1b1e6661
126+
Crashlytics: ccaac42660eb9351b9960c0d66106b0bcf99f4fa
127+
Fabric: f233c9492b3bbc1f04e3882986740f7988a58edb
128128
FormatterKit: 4b8f29acc9b872d5d12a63efb560661e8f2e1b98
129129
GoogleSignInRepacked: d357702618c555f38923576924661325eb1ef22b
130130
GoogleToolboxForMac: 91c824d21e85b31c2aae9bb011c5027c9b4e738f
@@ -136,13 +136,13 @@ SPEC CHECKSUMS:
136136
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
137137
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
138138
UIDeviceIdentifier: a959a6d4f51036b4180dd31fb26483a820f1cc46
139-
WordPressAuthenticator: e6e1c80aff95f1b2ad11e4477fcfe9f61aa8c49a
139+
WordPressAuthenticator: 56538a229185640b41912c10c3f1891c2cc9bbb9
140140
WordPressKit: a4a3849684f631a3abf579f6d3f15a32677cbb30
141141
WordPressShared: 063e1e8b1a7aaf635abf17f091a2d235a068abdc
142142
WordPressUI: af141587ec444f9af753a00605bd0d3f14d8d8a3
143143
wpxmlrpc: bfc572f62ce7ee897f6f38b098d2ba08732ecef4
144144
XLPagerTabStrip: c908b17cbf42fcd2598ee1adfc49bae25444d88a
145145

146-
PODFILE CHECKSUM: a2a2362208b6735d77e2c6358fbcdf29aead6bff
146+
PODFILE CHECKSUM: 579bb6345aecc3f27e78d220e137a749e9ee5f08
147147

148148
COCOAPODS: 1.5.3

WooCommerce/Classes/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private extension AppDelegate {
133133

134134
// Take advantage of a bug in UIAlertController
135135
// to style all UIAlertControllers with WC color
136-
self.window?.tintColor = StyleManager.wooCommerceBrandColor
136+
window?.tintColor = StyleManager.wooCommerceBrandColor
137137
}
138138

139139
/// Sets up FancyButton's UIAppearance.

WooCommerce/Classes/Model/Order+Woo.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,4 @@ extension Order {
1414

1515
return NSLocale(localeIdentifier: identifier).currencySymbol
1616
}
17-
18-
/// Determines if a shipping address exists.
19-
///
20-
var hasSeparateShippingDetail: Bool {
21-
return shippingAddress != nil
22-
}
23-
24-
/// FIXME: Creates an empty-string value Billing details, until i6 fix
25-
///
26-
func generateEmptyBillingAddress() -> Address {
27-
return Address(firstName: "", lastName: "", company: "", address1: "", address2: "", city: "", state: "", postcode: "", country: "", phone: "", email: "")
28-
}
2917
}

WooCommerce/Classes/ViewModels/OrderDetailsViewModel.swift

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,20 @@ class OrderDetailsViewModel {
6262
return order.customerNote ?? String()
6363
}
6464

65-
var shippingViewModel: ContactViewModel {
65+
var shippingViewModel: ContactViewModel? {
6666
if let shippingAddress = order.shippingAddress {
6767
return ContactViewModel(with: shippingAddress, contactType: ContactType.shipping)
6868
}
6969

70-
if let billingAddress = order.billingAddress {
71-
return ContactViewModel(with: billingAddress, contactType: ContactType.shipping)
72-
}
73-
74-
return ContactViewModel(with: order.generateEmptyBillingAddress(), contactType: ContactType.shipping)
75-
}
76-
var shippingAddress: String? {
77-
return shippingViewModel.formattedAddress
70+
return nil
7871
}
7972

8073
var billingViewModel: ContactViewModel? {
8174
if let billingAddress = order.billingAddress {
8275
return ContactViewModel(with: billingAddress, contactType: ContactType.billing)
8376
}
84-
return nil
85-
}
8677

87-
var billingAddress: String? {
88-
return billingViewModel?.formattedAddress
78+
return nil
8979
}
9080

9181
let subtotalLabel = NSLocalizedString("Subtotal", comment: "Subtotal label for payment view")

WooCommerce/Classes/ViewRelated/Dashboard/Settings/SettingsViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class SettingsViewController: UIViewController {
6868
func logOutUser() {
6969
WooAnalytics.shared.track(.logout)
7070
StoresManager.shared.deauthenticate()
71-
self.navigationController?.popToRootViewController(animated: true)
71+
navigationController?.popToRootViewController(animated: true)
7272
}
7373
}
7474

@@ -100,12 +100,12 @@ extension SettingsViewController: UITableViewDataSource {
100100
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
101101
let row = sections[indexPath.section].rows[indexPath.row]
102102
let cell = tableView.dequeueReusableCell(withIdentifier: row.reuseIdentifier, for: indexPath)
103-
if cell is LogOutTableViewCell {
104-
let logoutCell = cell as! LogOutTableViewCell
103+
if let logoutCell = cell as? LogOutTableViewCell {
105104
logoutCell.didSelectLogout = { [weak self] in
106105
self?.handleLogout()
107106
}
108107
}
108+
109109
return cell
110110
}
111111

0 commit comments

Comments
 (0)