@@ -37,8 +37,9 @@ public actor POSLocalCatalogEligibilityService: POSLocalCatalogEligibilityServic
3737 self . isLocalCatalogFeatureFlagEnabled = isLocalCatalogFeatureFlagEnabled
3838 self . remoteFeatureFlagProvider = remoteFeatureFlagProvider
3939 self . catalogSizeLimit = catalogSizeLimit ?? Constants . defaultCatalogSizeLimit
40+ // Eagerly start fetching the remote flag in the background
4041 Task {
41- _ = await isRemoteCatalogFeatureFlagEnabled ( )
42+ await self . fetchRemoteFlag ( )
4243 }
4344 }
4445
@@ -53,22 +54,15 @@ public actor POSLocalCatalogEligibilityService: POSLocalCatalogEligibilityServic
5354 }
5455
5556 /// Fetch and cache the remote feature flag value
56- /// Returns cached value if available, otherwise returns true without waiting for network
57+ /// Returns cached value if available, otherwise returns true (assumes eligible)
5758 private func isRemoteCatalogFeatureFlagEnabled( ) async -> Bool {
58- if let cached = cachedRemoteFeatureFlag {
59- return cached
60- }
61- // No cached value yet - assume eligible (true) without waiting for network
62- // Kick off the fetch in the background to cache for next time
63- Task { [ weak self] in
64- let value = await self ? . remoteFeatureFlagProvider ( ) ?? true
65- await self ? . cacheRemoteFeatureFlag ( value)
66- }
67- return true
59+ // Return cached value if we have one
60+ return cachedRemoteFeatureFlag ?? true
6861 }
6962
70- /// Cache the remote feature flag value (actor-isolated)
71- private func cacheRemoteFeatureFlag( _ value: Bool ) {
63+ /// Fetch the remote feature flag value and cache it (actor-isolated)
64+ private func fetchRemoteFlag( ) async {
65+ let value = await remoteFeatureFlagProvider ( )
7266 cachedRemoteFeatureFlag = value
7367 }
7468
0 commit comments