Skip to content

Commit c65ddb4

Browse files
committed
Use lightweight version for order list cells
1 parent 321fe19 commit c65ddb4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Modules/Sources/Yosemite/SnapshotsProvider/FetchResultSnapshotsProvider.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ public final class FetchResultSnapshotsProvider<MutableType: FetchResultSnapshot
179179
return nil
180180
}
181181
}
182+
183+
/// The lightweight version of `object(withID:)` method. Returns readonly objects without relationships.
184+
///
185+
public func lightweightObject(withID objectID: FetchResultSnapshotObjectID) -> MutableType.ReadOnlyType? {
186+
if let storageOrder = storage.loadObject(ofType: MutableType.self, with: objectID) {
187+
return storageOrder.toLightweightReadOnly()
188+
} else {
189+
return nil
190+
}
191+
}
182192
}
183193

184194
// MARK: - FetchedResultsController Activation

WooCommerce/Classes/ViewRelated/Orders/OrderListViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ extension OrderListViewModel {
326326

327327
/// Creates an `OrderListCellViewModel` for the `Order` pointed to by `objectID`.
328328
func cellViewModel(withID objectID: FetchResultSnapshotObjectID) -> OrderListCellViewModel? {
329-
guard let order = snapshotsProvider.object(withID: objectID) else {
329+
guard let order = snapshotsProvider.lightweightObject(withID: objectID) else {
330330
return nil
331331
}
332332

0 commit comments

Comments
 (0)