Skip to content

Commit

Permalink
Made SKHelperProduct support Equatable
Browse files Browse the repository at this point in the history
  • Loading branch information
russell-archer committed Oct 13, 2024
1 parent 46d9782 commit 4e30ac3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Sources/SKHelper/Core/SKHelperProduct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public import StoreKit
/// `SKHelperProduct` holds localized product information, along with a cached value for the user's entitlement to use the product.
@MainActor
@available(iOS 17.0, macOS 14.6, *)
public class SKHelperProduct: Identifiable {
public class SKHelperProduct: Identifiable, Equatable {

/// The unique `ProductId` for the `Product`.
public let id: ProductId
Expand Down Expand Up @@ -44,4 +44,6 @@ public class SKHelperProduct: Identifiable {
self.groupId = product.subscription?.subscriptionGroupID
self.groupLevel = product.subscription?.groupLevel ?? Int.max
}

nonisolated public static func == (lhs: SKHelperProduct, rhs: SKHelperProduct) -> Bool { lhs.id == rhs.id }
}
4 changes: 2 additions & 2 deletions Sources/SKHelper/Views/SKHelperStoreView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public struct SKHelperStoreView<Content: View>: View {
/// Creates the body of the view.
public var body: some View {

if store.hasProducts {
if hasProducts {
StoreView(products: products) { product in
VStack {
Image(product.id)
Expand All @@ -110,7 +110,7 @@ public struct SKHelperStoreView<Content: View>: View {
if let productDetails { SKHelperProductView(selectedProductId: $selectedProductId, showProductInfoSheet: $productSelected, productDetails: productDetails) }
else { SKHelperProductView(selectedProductId: $selectedProductId, showProductInfoSheet: $productSelected) }
}
.onChange(of: store.hasProducts) { hasProducts = store.hasProducts }
.onChange(of: store.products) { hasProducts = store.hasProducts }
} else {

VStack {
Expand Down

0 comments on commit 4e30ac3

Please sign in to comment.