From 72eac93b3cdb5b4da76ff308990d982b04e873c1 Mon Sep 17 00:00:00 2001 From: Alexandru Farcasanu Date: Tue, 22 Apr 2025 10:29:49 +0300 Subject: [PATCH 1/2] =?UTF-8?q?FXIOS-11952=20#25998=20=E2=81=83=20Remove?= =?UTF-8?q?=20jump=20back=20in=20feature=20flag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BrowserKit/Sources/Shared/Prefs.swift | 2 +- .../FeatureFlags/NimbusFlaggableFeature.swift | 3 -- .../JumpBackIn/JumpBackInSectionState.swift | 2 +- .../Home/JumpBackIn/JumpBackInViewModel.swift | 5 ++- .../HomePageSettingViewController.swift | 34 +++++++++---------- .../Nimbus/NimbusFeatureFlagLayer.swift | 19 ----------- .../Client/Telemetry/TelemetryWrapper.swift | 2 +- .../nimbus-features/homescreenFeature.yaml | 5 --- 8 files changed, 21 insertions(+), 51 deletions(-) diff --git a/BrowserKit/Sources/Shared/Prefs.swift b/BrowserKit/Sources/Shared/Prefs.swift index a87d8fd81e3f..90da109d7bfe 100644 --- a/BrowserKit/Sources/Shared/Prefs.swift +++ b/BrowserKit/Sources/Shared/Prefs.swift @@ -80,7 +80,6 @@ public struct PrefsKeys { public static let DebugSuffixKey = "DebugKey" public static let FirefoxSuggest = "FirefoxSuggest" public static let InactiveTabs = "InactiveTabsUserPrefsKey" - public static let JumpBackInSection = "JumpBackInSectionUserPrefsKey" public static let SearchBarPosition = "SearchBarPositionUsersPrefsKey" public static let SentFromFirefox = "SentFromFirefoxUserPrefsKey" } @@ -109,6 +108,7 @@ public struct PrefsKeys { public struct UserFeatureFlagPrefs { public static let ASPocketStories = "ASPocketStoriesUserPrefsKey" public static let BookmarksSection = "BookmarksSectionUserPrefsKey" + public static let JumpBackInSection = "JumpBackInSectionUserPrefsKey" public static let SponsoredShortcuts = "SponsoredShortcutsUserPrefsKey" public static let StartAtHome = "StartAtHomeUserPrefsKey" public static let TopSiteSection = "TopSitesUserPrefsKey" diff --git a/firefox-ios/Client/FeatureFlags/NimbusFlaggableFeature.swift b/firefox-ios/Client/FeatureFlags/NimbusFlaggableFeature.swift index 52e4d2046b7a..ddfcc8f65c07 100644 --- a/firefox-ios/Client/FeatureFlags/NimbusFlaggableFeature.swift +++ b/firefox-ios/Client/FeatureFlags/NimbusFlaggableFeature.swift @@ -25,7 +25,6 @@ enum NimbusFeatureFlagID: String, CaseIterable { case homepageRebuild case inactiveTabs case isToolbarCFREnabled - case jumpBackIn case loginAutofill case menuRefactor case menuRefactorHint @@ -110,8 +109,6 @@ struct NimbusFlaggableFeature: HasNimbusSearchBar { return FlagKeys.FirefoxSuggest case .inactiveTabs: return FlagKeys.InactiveTabs - case .jumpBackIn: - return FlagKeys.JumpBackInSection case .sentFromFirefox: return FlagKeys.SentFromFirefox // Cases where users do not have the option to manipulate a setting. diff --git a/firefox-ios/Client/Frontend/Home/Homepage Rebuild/JumpBackIn/JumpBackInSectionState.swift b/firefox-ios/Client/Frontend/Home/Homepage Rebuild/JumpBackIn/JumpBackInSectionState.swift index fab16d44ca24..7df034b9bd71 100644 --- a/firefox-ios/Client/Frontend/Home/Homepage Rebuild/JumpBackIn/JumpBackInSectionState.swift +++ b/firefox-ios/Client/Frontend/Home/Homepage Rebuild/JumpBackIn/JumpBackInSectionState.swift @@ -27,7 +27,7 @@ struct JumpBackInSectionState: StateType, Equatable, Hashable { windowUUID: WindowUUID ) { // TODO: FXIOS-11412 / 11226 - Move profile dependency and show section also based on feature flags - let shouldShowSection = profile.prefs.boolForKey(PrefsKeys.FeatureFlags.JumpBackInSection) ?? true + let shouldShowSection = profile.prefs.boolForKey(PrefsKeys.UserFeatureFlagPrefs.JumpBackInSection) ?? true self.init( windowUUID: windowUUID, jumpBackInTabs: [], diff --git a/firefox-ios/Client/Frontend/Home/JumpBackIn/JumpBackInViewModel.swift b/firefox-ios/Client/Frontend/Home/JumpBackIn/JumpBackInViewModel.swift index 8713ff285887..c7479b3bb677 100644 --- a/firefox-ios/Client/Frontend/Home/JumpBackIn/JumpBackInViewModel.swift +++ b/firefox-ios/Client/Frontend/Home/JumpBackIn/JumpBackInViewModel.swift @@ -307,9 +307,8 @@ extension JumpBackInViewModel: HomepageViewModelProtocol { } var isEnabled: Bool { - guard featureFlags.isFeatureEnabled(.jumpBackIn, checking: .buildAndUser) else { return false } - - return !isPrivate + let isEnabled = profile.prefs.boolForKey(PrefsKeys.UserFeatureFlagPrefs.JumpBackInSection) ?? true + return !isPrivate && isEnabled } func numberOfItemsInSection() -> Int { diff --git a/firefox-ios/Client/Frontend/Settings/HomepageSettings/HomePageSettingViewController.swift b/firefox-ios/Client/Frontend/Settings/HomepageSettings/HomePageSettingViewController.swift index f80c225b1efe..5cc9f9393d19 100644 --- a/firefox-ios/Client/Frontend/Settings/HomepageSettings/HomePageSettingViewController.swift +++ b/firefox-ios/Client/Frontend/Settings/HomepageSettings/HomePageSettingViewController.swift @@ -15,10 +15,6 @@ class HomePageSettingViewController: SettingsTableViewController, FeatureFlaggab var hasHomePage = false var wallpaperManager: WallpaperManagerInterface - var isJumpBackInSectionEnabled: Bool { - return featureFlags.isFeatureEnabled(.jumpBackIn, checking: .buildOnly) - } - var isWallpaperSectionEnabled: Bool { return wallpaperManager.canSettingsBeShown } @@ -128,23 +124,25 @@ class HomePageSettingViewController: SettingsTableViewController, FeatureFlaggab format: .Settings.Homepage.CustomizeFirefoxHome.ThoughtProvokingStoriesSubtitle, PocketAppName.shortName.rawValue) - let jumpBackInSetting = BoolSetting( - with: .jumpBackIn, - titleText: NSAttributedString(string: .Settings.Homepage.CustomizeFirefoxHome.JumpBackIn) - ) { value in - store.dispatch( - JumpBackInAction( - isEnabled: value, - windowUUID: self.windowUUID, - actionType: JumpBackInActionType.toggleShowSectionSetting - ) - ) - } - // Section ordering sectionItems.append(TopSitesSettings(settings: self)) - if isJumpBackInSectionEnabled { + if let profile { + let jumpBackInSetting = BoolSetting( + prefs: profile.prefs, + theme: themeManager.getCurrentTheme(for: windowUUID), + prefKey: PrefsKeys.UserFeatureFlagPrefs.JumpBackInSection, + defaultValue: true, + titleText: .Settings.Homepage.CustomizeFirefoxHome.JumpBackIn + ) { value in + store.dispatch( + JumpBackInAction( + isEnabled: value, + windowUUID: self.windowUUID, + actionType: JumpBackInActionType.toggleShowSectionSetting + ) + ) + } sectionItems.append(jumpBackInSetting) } diff --git a/firefox-ios/Client/Nimbus/NimbusFeatureFlagLayer.swift b/firefox-ios/Client/Nimbus/NimbusFeatureFlagLayer.swift index da2b809200fe..85822fc10bcf 100644 --- a/firefox-ios/Client/Nimbus/NimbusFeatureFlagLayer.swift +++ b/firefox-ios/Client/Nimbus/NimbusFeatureFlagLayer.swift @@ -41,9 +41,6 @@ final class NimbusFeatureFlagLayer { case .creditCardAutofillStatus: return checkNimbusForCreditCardAutofill(for: featureID, from: nimbus) - case .jumpBackIn: - return checkHomescreenSectionsFeature(for: featureID, from: nimbus) - case .firefoxSuggestFeature: return checkFirefoxSuggestFeature(from: nimbus) @@ -185,22 +182,6 @@ final class NimbusFeatureFlagLayer { } } - private func checkHomescreenSectionsFeature(for featureID: NimbusFeatureFlagID, - from nimbus: FxNimbus - ) -> Bool { - let config = nimbus.features.homescreenFeature.value() - var nimbusID: HomeScreenSection - - switch featureID { - case .jumpBackIn: nimbusID = HomeScreenSection.jumpBackIn - default: return false - } - - guard let status = config.sectionsEnabled[nimbusID] else { return false } - - return status - } - private func checkHomepageFeature(from nimbus: FxNimbus) -> Bool { let config = nimbus.features.homepageRebuildFeature.value() return config.enabled diff --git a/firefox-ios/Client/Telemetry/TelemetryWrapper.swift b/firefox-ios/Client/Telemetry/TelemetryWrapper.swift index 17c9a9a80163..20721ed5ca28 100644 --- a/firefox-ios/Client/Telemetry/TelemetryWrapper.swift +++ b/firefox-ios/Client/Telemetry/TelemetryWrapper.swift @@ -306,7 +306,7 @@ class TelemetryWrapper: TelemetryWrapperProtocol, FeatureFlaggable { } // Homepage section preferences - let isJumpBackInEnabled = featureFlags.isFeatureEnabled(.jumpBackIn, checking: .buildAndUser) + let isJumpBackInEnabled = profile.prefs.boolForKey(PrefsKeys.UserFeatureFlagPrefs.JumpBackInSection) ?? true GleanMetrics.Preferences.jumpBackIn.set(isJumpBackInEnabled) let isBookmarksEnabled = prefs.boolForKey(PrefsKeys.UserFeatureFlagPrefs.BookmarksSection) ?? true diff --git a/firefox-ios/nimbus-features/homescreenFeature.yaml b/firefox-ios/nimbus-features/homescreenFeature.yaml index 12075025e898..6f2eb587f38d 100644 --- a/firefox-ios/nimbus-features/homescreenFeature.yaml +++ b/firefox-ios/nimbus-features/homescreenFeature.yaml @@ -9,7 +9,6 @@ features: type: Map default: { - "jump-back-in": true, "recent-explorations": false, } prefer-switch-to-open-tab: @@ -22,7 +21,6 @@ features: - channel: developer value: { "sections-enabled": { - "jump-back-in": true, "recent-explorations": false, }, "prefer-switch-to-open-tab": true @@ -30,7 +28,6 @@ features: - channel: beta value: { "sections-enabled": { - "jump-back-in": true, "recent-explorations": false, }, "prefer-switch-to-open-tab": false @@ -40,7 +37,5 @@ enums: HomeScreenSection: description: The identifiers for the sections of the homescreen. variants: - jump-back-in: - description: The tabs the user was looking immediately before being interrupted. recent-explorations: description: The tab groups From 997a32669d87a3b87f9192379eb5755bf238eb0e Mon Sep 17 00:00:00 2001 From: Alexandru Farcasanu Date: Tue, 22 Apr 2025 11:21:23 +0300 Subject: [PATCH 2/2] Removing some tests --- .../ClientTests/FeatureFlagManagerTests.swift | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/firefox-ios/firefox-ios-tests/Tests/ClientTests/FeatureFlagManagerTests.swift b/firefox-ios/firefox-ios-tests/Tests/ClientTests/FeatureFlagManagerTests.swift index 6eaadd67fe22..65d68d428f6d 100644 --- a/firefox-ios/firefox-ios-tests/Tests/ClientTests/FeatureFlagManagerTests.swift +++ b/firefox-ios/firefox-ios-tests/Tests/ClientTests/FeatureFlagManagerTests.swift @@ -36,8 +36,6 @@ class FeatureFlagManagerTests: XCTestCase, FeatureFlaggable { XCTAssertTrue(featureFlags.isFeatureEnabled(.bottomSearchBar, checking: .userOnly)) XCTAssertTrue(featureFlags.isFeatureEnabled(.inactiveTabs, checking: .buildOnly)) XCTAssertTrue(featureFlags.isFeatureEnabled(.inactiveTabs, checking: .userOnly)) - XCTAssertTrue(featureFlags.isFeatureEnabled(.jumpBackIn, checking: .buildOnly)) - XCTAssertTrue(featureFlags.isFeatureEnabled(.jumpBackIn, checking: .userOnly)) XCTAssertTrue(featureFlags.isFeatureEnabled(.reportSiteIssue, checking: .buildOnly)) XCTAssertTrue(featureFlags.isFeatureEnabled(.reportSiteIssue, checking: .userOnly)) } @@ -46,22 +44,6 @@ class FeatureFlagManagerTests: XCTestCase, FeatureFlaggable { XCTAssertEqual(featureFlags.getCustomState(for: .searchBarPosition), SearchBarPosition.top) } - // Changing the prefs manually, to make sure settings are respected through - // the FFMs interface - func testManagerRespectsProfileChangesForBoolSettings() { - let mockProfile = MockProfile(databasePrefix: "FeatureFlagsManagerTests_") - mockProfile.prefs.clearAll() - LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: mockProfile) - - XCTAssertTrue(featureFlags.isFeatureEnabled(.jumpBackIn, checking: .buildOnly)) - XCTAssertTrue(featureFlags.isFeatureEnabled(.jumpBackIn, checking: .userOnly)) - // Changing the prefs manually, to make sure settings are respected through - // the FFMs interface - mockProfile.prefs.setBool(false, forKey: PrefsKeys.FeatureFlags.JumpBackInSection) - XCTAssertTrue(featureFlags.isFeatureEnabled(.jumpBackIn, checking: .buildOnly)) - XCTAssertFalse(featureFlags.isFeatureEnabled(.jumpBackIn, checking: .userOnly)) - } - // Changing the prefs manually, to make sure settings are respected through // the FFMs interface func testManagerRespectsProfileChangesForCustomSettings() { @@ -76,14 +58,6 @@ class FeatureFlagManagerTests: XCTestCase, FeatureFlaggable { XCTAssertEqual(featureFlags.getCustomState(for: .searchBarPosition), SearchBarPosition.bottom) } - func testManagerInterfaceForUpdatingBoolFlags() { - XCTAssertTrue(featureFlags.isFeatureEnabled(.jumpBackIn, checking: .buildOnly)) - XCTAssertTrue(featureFlags.isFeatureEnabled(.jumpBackIn, checking: .userOnly)) - featureFlags.set(feature: .jumpBackIn, to: false) - XCTAssertTrue(featureFlags.isFeatureEnabled(.jumpBackIn, checking: .buildOnly)) - XCTAssertFalse(featureFlags.isFeatureEnabled(.jumpBackIn, checking: .userOnly)) - } - func testManagerInterfaceForUpdatingCustomFlags() { // Search Bar XCTAssertEqual(featureFlags.getCustomState(for: .searchBarPosition), SearchBarPosition.top)