Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mludowise-stripe committed Sep 24, 2024
1 parent 599f532 commit 920db0e
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,17 @@ class AppSettings {
}

func selectedMerchant(appInfo: AppInfo?) -> MerchantInfo? {
// Default to the first available merchant if this is the first time opening the app
guard let merchantId = UserDefaults.standard.string(forKey: Constants.selectedMerchantKey) else {
return appInfo?.availableMerchants.first
}
return appInfo?.availableMerchants.first(where: {

// If the merchant is in the list of available merchants, then use its display name
let displayName = appInfo?.availableMerchants.first(where: {
$0.merchantId == merchantId
}) ?? .init(displayName: nil, merchantId: merchantId)
})?.displayName

return .init(displayName: displayName, merchantId: merchantId)
}

func setSelectedMerchant(merchant: MerchantInfo?) {
Expand Down

0 comments on commit 920db0e

Please sign in to comment.