Skip to content

Commit

Permalink
Paywalls: sort offerings list in sample app (#2965)
Browse files Browse the repository at this point in the history
I noticed that every time I opened this it was in a different order.
That's because `dictionary.values` is non-deterministic, so this sorts
them by description now.
  • Loading branch information
NachoSoto committed Sep 1, 2023
1 parent 4273e38 commit 51171e3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Tests/TestingApps/SimpleApp/SimpleApp/Views/OfferingsList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SwiftUI
struct OfferingsList: View {

@State
private var offerings: Result<Offerings, NSError>?
private var offerings: Result<[Offering], NSError>?

@State
private var selectedOffering: Offering?
Expand All @@ -22,7 +22,12 @@ struct OfferingsList: View {
.navigationTitle("Offerings")
.task {
do {
self.offerings = .success(try await Purchases.shared.offerings())
self.offerings = .success(
try await Purchases.shared.offerings()
.all
.map(\.value)
.sorted { $0.serverDescription > $1.serverDescription }
)
} catch let error as NSError {
self.offerings = .failure(error)
}
Expand All @@ -33,7 +38,7 @@ struct OfferingsList: View {
private var content: some View {
switch self.offerings {
case let .success(offerings):
self.list(with: offerings.all.values)
self.list(with: offerings)
.sheet(item: self.$selectedOffering) { offering in
PaywallView(offering: offering)
}
Expand Down

0 comments on commit 51171e3

Please sign in to comment.