Skip to content

Commit b1caa89

Browse files
committed
Use array comparision rathar than set comparition because set comparision seems to be having some bugs
1 parent 20ca9f7 commit b1caa89

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

WooCommerce/Classes/ViewRelated/Products/Variations/ProductVariationGenerator.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,21 @@ import Yosemite
55
///
66
struct ProductVariationGenerator {
77

8-
/// Group a colection of attribute options.
8+
/// Group a collection of attribute options.
99
/// EG: [Size: Large, Color: Black, Fabric: Cotton]
1010
///
11-
private struct Combination: Hashable {
11+
private struct Combination: Hashable, Equatable {
1212
let options: [Option]
13+
14+
static func == (lhs: Combination, rhs: Combination) -> Bool {
15+
Set(lhs.options) == Set(rhs.options)
16+
}
1317
}
1418

1519
/// Represents an attribute option.
1620
/// EG: Size: Large
1721
///
18-
private struct Option: Hashable {
22+
private struct Option: Hashable, Equatable {
1923
let attributeID: Int64
2024
let attributeName: String
2125
let value: String
@@ -56,10 +60,10 @@ struct ProductVariationGenerator {
5660
}
5761

5862
// Filter existing combinations.
59-
let existingSet = Set(existingCombinations)
60-
return combinations.filter { combination in
61-
!existingSet.contains(combination)
63+
let unique = combinations.filter { combination in
64+
!existingCombinations.contains(combination)
6265
}
66+
return unique
6367
}
6468

6569
/// Convert the provided combinations into `[CreateProductVariation]` types that are consumed by our Yosemite stores.

0 commit comments

Comments
 (0)