Skip to content

Commit 6257ba5

Browse files
joshhealdstaskus
authored andcommitted
Use PointOfSaleObservableItemsController when GRDB is available
When grdbManager, catalogSyncCoordinator, and the pointOfSaleLocalCatalogi1 feature flag are all present, use the new PointOfSaleObservableItemsController backed by GRDBObservableDataSource instead of the standard PointOfSaleItemsController. This enables reactive database-driven item lists for stores with local catalog sync enabled.
1 parent 06cb40f commit 6257ba5

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

Modules/Sources/PointOfSale/Presentation/PointOfSaleEntryPointView.swift

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,23 @@ public struct PointOfSaleEntryPointView: View {
6666
services: POSDependencyProviding) {
6767
self.onPointOfSaleModeActiveStateChange = onPointOfSaleModeActiveStateChange
6868

69-
self.itemsController = PointOfSaleItemsController(
70-
itemProvider: PointOfSaleItemService(currencySettings: services.currency.currencySettings),
71-
itemFetchStrategyFactory: itemFetchStrategyFactory,
72-
analyticsProvider: services.analytics
73-
)
69+
// Use observable controller with GRDB if available and feature flag is enabled, otherwise fall back to standard controller
70+
// Note: We check feature flag here for eligibility. Once eligibility checking is
71+
// refactored to be more centralized, this check can be simplified.
72+
let isGRDBEnabled = services.featureFlags.isFeatureFlagEnabled(.pointOfSaleLocalCatalogi1)
73+
if let grdbManager = grdbManager, catalogSyncCoordinator != nil, isGRDBEnabled {
74+
self.itemsController = PointOfSaleObservableItemsController(
75+
siteID: siteID,
76+
grdbManager: grdbManager,
77+
currencySettings: services.currency.currencySettings
78+
)
79+
} else {
80+
self.itemsController = PointOfSaleItemsController(
81+
itemProvider: PointOfSaleItemService(currencySettings: services.currency.currencySettings),
82+
itemFetchStrategyFactory: itemFetchStrategyFactory,
83+
analyticsProvider: services.analytics
84+
)
85+
}
7486
self.purchasableItemsSearchController = PointOfSaleItemsController(
7587
itemProvider: PointOfSaleItemService(currencySettings: services.currency.currencySettings),
7688
itemFetchStrategyFactory: itemFetchStrategyFactory,

0 commit comments

Comments
 (0)