Skip to content

Commit e6c65df

Browse files
committed
Merge branch 'backlog/WOOMOB-869-remove-pos-tab-i2-feature-flag-with-refactoring' into feat/WOOMOB-935-refactor-pos-entry-point
# Conflicts: # WooCommerce/Classes/POS/Presentation/PointOfSaleEntryPointView.swift # WooCommerce/Classes/POS/Utils/PreviewHelpers.swift
2 parents 827f23e + a35cc78 commit e6c65df

29 files changed

+783
-1641
lines changed

Modules/Sources/Experiments/DefaultFeatureFlagService.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
8888
return true
8989
case .productImageOptimizedHandling:
9090
return true
91-
case .pointOfSaleAsATabi2:
92-
return true
9391
case .pointOfSaleOrdersi1:
9492
return true
9593
case .pointOfSaleOrdersi2:

Modules/Sources/Experiments/FeatureFlag.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,6 @@ public enum FeatureFlag: Int {
183183
///
184184
case pointOfSaleReceipts
185185

186-
/// Enables displaying POS as a tab in the tab bar for stores in eligible countries
187-
///
188-
case pointOfSaleAsATabi2
189-
190186
/// Enables displaying Point Of Sale details in order list and order details
191187
///
192188
case pointOfSaleOrdersi1

Modules/Sources/Yosemite/Tools/Plugins/PluginsService.swift

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
import Foundation
2-
import WooFoundation
32
import protocol Storage.StorageManagerType
43

54
/// A service for system plugins.
65
public protocol PluginsServiceProtocol {
7-
/// Waits for a specific plugin to be available in storage.
8-
/// - Parameters:
9-
/// - siteID: The site ID to search for the plugin.
10-
/// - pluginPath: The plugin's file path (e.g., "woocommerce/woocommerce.php" for WooCommerce).
11-
/// - isActive: Whether the plugin is active or not.
12-
/// - Returns: The SystemPlugin when found in storage.
13-
func waitForPluginInStorage(siteID: Int64, pluginPath: String, isActive: Bool) async -> SystemPlugin
14-
156
/// Loads a specific plugin from storage synchronously.
167
/// - Parameters:
178
/// - siteID: The site ID to search for the plugin.
@@ -37,36 +28,6 @@ public class PluginsService: PluginsServiceProtocol {
3728
self.storageManager = storageManager
3829
}
3930

40-
@MainActor
41-
public func waitForPluginInStorage(siteID: Int64, pluginPath: String, isActive: Bool) async -> SystemPlugin {
42-
let predicate = \StorageSystemPlugin.siteID == siteID && \StorageSystemPlugin.plugin == pluginPath && \StorageSystemPlugin.active == isActive
43-
let pluginDescriptor = NSSortDescriptor(keyPath: \StorageSystemPlugin.plugin, ascending: true)
44-
let resultsController = ResultsController<StorageSystemPlugin>(storageManager: storageManager,
45-
matching: predicate,
46-
fetchLimit: 1,
47-
sortedBy: [pluginDescriptor])
48-
do {
49-
try resultsController.performFetch()
50-
if let plugin = resultsController.fetchedObjects.first {
51-
return plugin
52-
}
53-
} catch {
54-
DDLogError("Error loading plugin \(pluginPath) for site \(siteID) initially: \(error.localizedDescription)")
55-
}
56-
57-
return await withCheckedContinuation { continuation in
58-
var hasResumed = false
59-
resultsController.onDidChangeContent = {
60-
guard let plugin = resultsController.fetchedObjects.first,
61-
!hasResumed else {
62-
return
63-
}
64-
hasResumed = true
65-
continuation.resume(returning: plugin)
66-
}
67-
}
68-
}
69-
7031
@MainActor
7132
public func loadPluginInStorage(siteID: Int64, plugin: Plugin, isActive: Bool?) -> SystemPlugin? {
7233
storageManager.viewStorage.loadSystemPlugin(siteID: siteID,

Modules/Tests/YosemiteTests/Tools/Plugins/PluginsServiceTests.swift

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,6 @@ struct PluginsServiceTests {
1313
sut = PluginsService(storageManager: storageManager)
1414
}
1515

16-
@Test func waitForPluginInStorage_returns_plugin_when_already_in_storage() async {
17-
// Given
18-
await storageManager.reset()
19-
storageManager.insertPlugin(siteID: siteID, plugin: .wooCommerce, isActive: true, version: "1.0.0")
20-
21-
// When
22-
let result = await sut.waitForPluginInStorage(siteID: siteID, pluginPath: "woocommerce/woocommerce.php", isActive: true)
23-
24-
// Then
25-
#expect(result.siteID == siteID)
26-
#expect(result.plugin == "woocommerce/woocommerce.php")
27-
#expect(result.active == true)
28-
#expect(result.version == "1.0.0")
29-
}
30-
31-
@Test func waitForPluginInStorage_waits_to_return_plugin_when_not_in_storage_initially() async {
32-
// Given
33-
// Resets any existing state, otherwise test might fail if run multiple times.
34-
await storageManager.reset()
35-
36-
// When
37-
async let plugin = sut.waitForPluginInStorage(siteID: siteID, pluginPath: "woocommerce/woocommerce.php", isActive: true)
38-
#expect(storageManager.viewStorage.loadSystemPlugins(siteID: siteID).count == 0)
39-
storageManager.insertPlugin(siteID: siteID, plugin: .wooCommerce, isActive: true, version: "2.0.0")
40-
#expect(storageManager.viewStorage.loadSystemPlugins(siteID: siteID).count == 1)
41-
42-
// Then
43-
let result = await plugin
44-
#expect(result.siteID == siteID)
45-
#expect(result.plugin == "woocommerce/woocommerce.php")
46-
#expect(result.active == true)
47-
#expect(result.version == "2.0.0")
48-
}
49-
5016
// MARK: - `loadPluginInStorage`
5117

5218
@Test(arguments: [(Plugin.wooCommerce, true, "1.5.0"),

RELEASE-NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
23.4
55
-----
6-
6+
- [*] Order details: Fixes broken country selector navigation and "Non editable banner" width. [https://github.com/woocommerce/woocommerce-ios/pull/16171]
77

88
23.3
99
-----

WooCommerce/Classes/POS/Controllers/POSEntryPointController.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import SwiftUI
2-
import protocol Experiments.FeatureFlagService
32

43
public protocol POSEntryPointEligibilityCheckerProtocol {
5-
/// Checks the initial visibility of the POS tab.
6-
func checkInitialVisibility() -> Bool
7-
/// Checks the final visibility of the POS tab.
8-
func checkVisibility() async -> Bool
94
/// Determines whether the site is eligible for POS.
105
func checkEligibility() async -> POSEligibilityState
116
/// Refreshes the eligibility state based on the provided ineligible reason.
@@ -15,17 +10,10 @@ public protocol POSEntryPointEligibilityCheckerProtocol {
1510
@Observable final class POSEntryPointController {
1611
private(set) var eligibilityState: POSEligibilityState?
1712
private let posEligibilityChecker: POSEntryPointEligibilityCheckerProtocol
18-
private let featureFlagService: POSFeatureFlagProviding
1913

20-
init(eligibilityChecker: POSEntryPointEligibilityCheckerProtocol,
21-
featureFlagService: POSFeatureFlagProviding) {
14+
init(eligibilityChecker: POSEntryPointEligibilityCheckerProtocol) {
2215
self.posEligibilityChecker = eligibilityChecker
23-
self.featureFlagService = featureFlagService
2416

25-
guard featureFlagService.isFeatureFlagEnabled(.pointOfSaleAsATabi2) else {
26-
self.eligibilityState = .eligible
27-
return
28-
}
2917
Task { @MainActor in
3018
eligibilityState = await posEligibilityChecker.checkEligibility()
3119
}

WooCommerce/Classes/POS/Models/PointOfSaleSettingsController.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,6 @@ final class MockPointOfSaleSettingsService: PointOfSaleSettingsServiceProtocol {
7171
}
7272

7373
final class PluginsServicePreview: PluginsServiceProtocol {
74-
func waitForPluginInStorage(siteID: Int64, pluginPath: String, isActive: Bool) async -> SystemPlugin {
75-
return SystemPlugin(siteID: 1234,
76-
plugin: "",
77-
name: "",
78-
version: "",
79-
versionLatest: "",
80-
url: "",
81-
authorName: "",
82-
authorUrl: "",
83-
networkActivated: false,
84-
active: true)
85-
}
86-
8774
func loadPluginInStorage(siteID: Int64, plugin: Plugin, isActive: Bool?) -> SystemPlugin? {
8875
return SystemPlugin(siteID: 1234,
8976
plugin: "",

WooCommerce/Classes/POS/Presentation/PointOfSaleEntryPointView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public struct PointOfSaleEntryPointView: View {
103103
analyticsProvider: services.analytics
104104
)
105105
self.barcodeScanService = barcodeScanService
106-
self.posEntryPointController = POSEntryPointController(eligibilityChecker: posEligibilityChecker, featureFlagService: services.featureFlags)
106+
self.posEntryPointController = POSEntryPointController(eligibilityChecker: posEligibilityChecker)
107107
let ordersController = POSOrderListController(orderListFetchStrategyFactory: orderListFetchStrategyFactory)
108108
self.orderListModel = POSOrderListModel(ordersController: ordersController, receiptSender: receiptSender)
109109
self.siteTimezone = siteTimezone

WooCommerce/Classes/POS/TabBar/POSTabCoordinator.swift

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ import class WooFoundationCore.CurrencyFormatter
88
import struct NetworkingCore.JetpackSite
99
import struct Combine.AnyPublisher
1010

11+
protocol POSTabVisibilityCheckerProtocol {
12+
/// Checks the initial visibility of the POS tab.
13+
func checkInitialVisibility() -> Bool
14+
/// Checks the final visibility of the POS tab.
15+
func checkVisibility() async -> Bool
16+
}
17+
1118
/// View controller that provides the tab bar item for the Point of Sale tab.
1219
/// It is never visible on the screen, only used to provide the tab bar item as all POS UI is full-screen.
1320
final class POSTabViewController: UIViewController {
@@ -23,7 +30,7 @@ final class POSTabViewController: UIViewController {
2330
/// Coordinator for the Point of Sale tab.
2431
///
2532
final class POSTabCoordinator {
26-
private(set) var siteID: Int64
33+
private let siteID: Int64
2734
private let tabContainerController: TabContainerController
2835
private let viewControllerToPresent: UIViewController
2936
private let storesManager: StoresManager
@@ -109,49 +116,6 @@ final class POSTabCoordinator {
109116
func onTabSelected() {
110117
presentPOSView(siteID: siteID)
111118
}
112-
113-
func didSwitchStore(id: Int64) {
114-
self.siteID = id
115-
116-
// Resets lazy properties so they get recreated with new siteID
117-
posItemFetchStrategyFactory = PointOfSaleItemFetchStrategyFactory(
118-
siteID: siteID,
119-
credentials: credentials,
120-
selectedSite: defaultSitePublisher,
121-
appPasswordSupportState: isAppPasswordSupported
122-
)
123-
124-
posPopularItemFetchStrategyFactory =
125-
PointOfSaleFixedItemFetchStrategyFactory(
126-
fixedStrategy: posItemFetchStrategyFactory.popularStrategy()
127-
)
128-
129-
posCouponFetchStrategyFactory = PointOfSaleCouponFetchStrategyFactory(
130-
siteID: siteID,
131-
currencySettings: currencySettings,
132-
credentials: credentials,
133-
selectedSite: defaultSitePublisher,
134-
appPasswordSupportState: isAppPasswordSupported,
135-
storage: storageManager
136-
)
137-
138-
posCouponProvider = PointOfSaleCouponService(
139-
siteID: siteID,
140-
currencySettings: currencySettings,
141-
credentials: credentials,
142-
selectedSite: defaultSitePublisher,
143-
appPasswordSupportState: isAppPasswordSupported,
144-
storage: storageManager
145-
)
146-
147-
barcodeScanService = PointOfSaleBarcodeScanService(
148-
siteID: siteID,
149-
credentials: credentials,
150-
selectedSite: defaultSitePublisher,
151-
appPasswordSupportState: isAppPasswordSupported,
152-
currencySettings: currencySettings
153-
)
154-
}
155119
}
156120

157121
private extension POSTabCoordinator {

WooCommerce/Classes/POS/Utils/PreviewHelpers.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,10 @@ struct POSPreviewHelpers {
234234
searchHistoryService: POSSearchHistoryProviding = PointOfSalePreviewHistoryService(),
235235
popularItemsController: PointOfSaleItemsControllerProtocol = PointOfSalePreviewItemsController(),
236236
barcodeScanService: PointOfSaleBarcodeScanServiceProtocol = PointOfSalePreviewBarcodeScanService(),
237-
analytics: POSAnalyticsProviding = EmptyPOSAnalytics(),
238-
featureFlags: POSFeatureFlagProviding = EmptyPOSFeatureFlags()
237+
analytics: POSAnalyticsProviding = EmptyPOSAnalytics()
239238
) -> PointOfSaleAggregateModel {
240239
return PointOfSaleAggregateModel(
241-
entryPointController: POSEntryPointController(eligibilityChecker: PointOfSalePreviewTabEligibilityChecker(),
242-
featureFlagService: featureFlags),
240+
entryPointController: POSEntryPointController(eligibilityChecker: PointOfSalePreviewTabEligibilityChecker()),
243241
itemsController: itemsController,
244242
purchasableItemsSearchController: purchasableItemsSearchController,
245243
couponsController: couponsController,
@@ -415,8 +413,6 @@ final class PointOfSalePreviewBarcodeScanService: PointOfSaleBarcodeScanServiceP
415413
}
416414

417415
final class PointOfSalePreviewTabEligibilityChecker: POSEntryPointEligibilityCheckerProtocol {
418-
func checkInitialVisibility() -> Bool { true }
419-
func checkVisibility() async -> Bool { true }
420416
func checkEligibility() async -> POSEligibilityState { .eligible }
421417
func refreshEligibility(ineligibleReason: POSIneligibleReason) async throws -> POSEligibilityState { .eligible }
422418
}

0 commit comments

Comments
 (0)