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

Core Data: Migrate storage usage for ShippingMethodStore #14568

Merged
merged 3 commits into from
Dec 4, 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 @@ -13,6 +13,7 @@
- [Internal] Updated storage usage in CouponStore [https://github.com/woocommerce/woocommerce-ios/pull/14530]
- [Internal] Update storage usage for BlazeStore [https://github.com/woocommerce/woocommerce-ios/pull/14532]
- [Internal] Updated storage usage in ProductShippingClassStore [https://github.com/woocommerce/woocommerce-ios/pull/14520]
- [Internal] Updated storage usage in ShippingMethodStore [https://github.com/woocommerce/woocommerce-ios/pull/14568]
- [Internal] Updated storage usage in TaxStore [https://github.com/woocommerce/woocommerce-ios/pull/14567]
- [Internal] Updated storage usage in SystemStatusStore [https://github.com/woocommerce/woocommerce-ios/pull/14559]
- [Internal] Updated storage usage in SitePluginStore [https://github.com/woocommerce/woocommerce-ios/pull/14560]
Expand Down
15 changes: 3 additions & 12 deletions Yosemite/Yosemite/Stores/ShippingMethodStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import Storage
public final class ShippingMethodStore: Store {
private let remote: ShippingMethodsRemote

private lazy var sharedDerivedStorage: StorageType = {
return storageManager.writerDerivedStorage
}()

public init(remote: ShippingMethodsRemote,
dispatcher: Dispatcher,
storageManager: StorageManagerType,
Expand Down Expand Up @@ -77,15 +73,10 @@ private extension ShippingMethodStore {
/// Triggers `completion` on main thread.
///
func upsertShippingMethodsInBackground(siteID: Int64, readOnlyMethods: [ShippingMethod], completion: @escaping () -> Void) {
let derivedStorage = sharedDerivedStorage
derivedStorage.perform { [weak self] in
storageManager.performAndSave({ [weak self] storage in
guard let self else { return }
self.upsertShippingMethods(siteID: siteID, readOnlyMethods: readOnlyMethods, in: derivedStorage)
}

storageManager.saveDerivedType(derivedStorage: derivedStorage) {
DispatchQueue.main.async(execute: completion)
}
self.upsertShippingMethods(siteID: siteID, readOnlyMethods: readOnlyMethods, in: storage)
}, completion: completion, on: .main)
}

/// Updates or inserts Readonly `ShippingMethod` entities in specified storage.
Expand Down