@@ -138,20 +138,43 @@ class JetpackFeaturesRemovalCoordinator: NSObject {
138138 }
139139
140140 /// Used to determine if the Jetpack features are enabled based on the current app UI type.
141+ /// This way we ensure features are not removed before reloading the UI.
142+ /// But if this function is called from a background thread, we determine if the Jetpack Features
143+ /// are enabled based on the removal phase regardless of the app UI state.
141144 /// Default root view coordinator is used.
142145 @objc
143146 static func jetpackFeaturesEnabled( ) -> Bool {
147+ guard Thread . isMainThread else {
148+ return shouldEnableJetpackFeatures ( )
149+ }
144150 return jetpackFeaturesEnabled ( rootViewCoordinator: . shared)
145151 }
146152
147153 /// Used to determine if the Jetpack features are enabled based on the current app UI type.
148154 /// This way we ensure features are not removed before reloading the UI.
155+ /// But if this function is called from a background thread, we determine if the Jetpack Features
156+ /// are enabled based on the removal phase regardless of the app UI state.
149157 /// Using two separate methods (rather than one method with a default argument) because Obj-C.
150158 /// - Returns: `true` if UI type is normal, and `false` if UI type is simplified.
151159 static func jetpackFeaturesEnabled( rootViewCoordinator: RootViewCoordinator ) -> Bool {
160+ guard Thread . isMainThread else {
161+ return shouldEnableJetpackFeatures ( )
162+ }
152163 return rootViewCoordinator. currentAppUIType == . normal
153164 }
154165
166+
167+ /// Used to determine if the Jetpack features are enabled based on the removal phase regardless of the app UI state.
168+ private static func shouldEnableJetpackFeatures( featureFlagStore: RemoteFeatureFlagStore = RemoteFeatureFlagStore ( ) ) -> Bool {
169+ let phase = generalPhase ( )
170+ switch phase {
171+ case . four, . newUsers, . selfHosted:
172+ return false
173+ default :
174+ return true
175+ }
176+ }
177+
155178 /// Used to display feature-specific or feature-collection overlays.
156179 /// - Parameters:
157180 /// - viewController: The view controller where the overlay should be presented in.
0 commit comments