Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Crash] Fix crash when searching products in order product selector #14095

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [*] Payments: Fixed a bug preventing payments onboarding from being automatically hidden when complete [https://github.com/woocommerce/woocommerce-ios/pull/14017]
- [*] Payments: Give a specific label to Tap to Pay trial payments [https://github.com/woocommerce/woocommerce-ios/pull/14022]
- [*] Some error views were misaligned on iPad when the store was not a WordPress site or didn't have Jetpack installed. Now, everything is perfectly centered. [https://github.com/woocommerce/woocommerce-ios/pull/13991]
- [*] Orders: Fixed a crash when searching for products to add to an order. [https://github.com/woocommerce/woocommerce-ios/pull/14095]

20.6
-----
Expand Down
8 changes: 4 additions & 4 deletions Yosemite/Yosemite/Stores/ProductStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,13 @@ private extension ProductStore {
}

func searchInCache(siteID: Int64, keyword: String, pageSize: Int, onCompletion: @escaping (Bool) -> Void) {
let namePredicate = NSPredicate(format: "name LIKE[c] %@", keyword)
let namePredicate = NSPredicate(format: "name CONTAINS[c] %@", keyword)
let sitePredicate = NSPredicate(format: "siteID == %lld", siteID)
let predicate = NSCompoundPredicate(andPredicateWithSubpredicates: [namePredicate, sitePredicate])

let results = sharedDerivedStorage.allObjects(ofType: StorageProduct.self,
matching: predicate,
sortedBy: nil)
let results = storageManager.viewStorage.allObjects(ofType: StorageProduct.self,
matching: predicate,
sortedBy: nil)

handleSearchResults(siteID: siteID,
keyword: keyword,
Expand Down