Skip to content

Commit e47e85b

Browse files
Refactor FXIOS-12703 [Homepage Redesign - Stories] Unify section removal under stories flag (backport #27806) (#27827)
* Refactor FXIOS-12703 [Homepage Redesign - Stories] Unify section removal under stories flag (#27806) (cherry picked from commit 9df533e) Co-authored-by: Foxbolts <[email protected]>
1 parent 1465d9d commit e47e85b

File tree

16 files changed

+50
-202
lines changed

16 files changed

+50
-202
lines changed

firefox-ios/Client/FeatureFlags/NimbusFlaggableFeature.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ enum NimbusFeatureFlagID: String, CaseIterable {
2121
case feltPrivacyFeltDeletion
2222
case feltPrivacySimplifiedUI
2323
case firefoxSuggestFeature
24-
case hntBookmarksSection
2524
case hntContentFeedRefresh
26-
case hntCusomizationSection
27-
case hntJumpBackInSection
2825
case hntSponsoredShortcuts
2926
case hntTopSitesVisualRefresh
3027
case homepageRebuild
@@ -123,10 +120,6 @@ struct NimbusFlaggableFeature: HasNimbusSearchBar {
123120
return FlagKeys.SearchBarPosition
124121
case .firefoxSuggestFeature:
125122
return FlagKeys.FirefoxSuggest
126-
case .hntBookmarksSection:
127-
return FlagKeys.BookmarksSection
128-
case .hntJumpBackInSection:
129-
return FlagKeys.JumpBackInSection
130123
case .hntSponsoredShortcuts:
131124
return FlagKeys.SponsoredShortcuts
132125
case .inactiveTabs:
@@ -146,7 +139,6 @@ struct NimbusFlaggableFeature: HasNimbusSearchBar {
146139
.feltPrivacyFeltDeletion,
147140
.feltPrivacySimplifiedUI,
148141
.hntContentFeedRefresh,
149-
.hntCusomizationSection,
150142
.hntTopSitesVisualRefresh,
151143
.homepageRebuild,
152144
.homepageRedesign,

firefox-ios/Client/Frontend/Home/Bookmarks/BookmarksViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ extension BookmarksViewModel: HomepageViewModelProtocol, FeatureFlaggable {
111111
}
112112

113113
var isEnabled: Bool {
114-
return featureFlags.isFeatureEnabled(.hntBookmarksSection, checking: .userOnly)
114+
return !featureFlags.isFeatureEnabled(.homepageStoriesRedesign, checking: .buildOnly)
115115
}
116116

117117
var hasData: Bool {

firefox-ios/Client/Frontend/Home/Homepage Rebuild/Bookmark/BookmarksSectionState.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ struct BookmarksSectionState: StateType, Equatable, Hashable {
2121
)
2222

2323
init(profile: Profile = AppContainer.shared.resolve(), windowUUID: WindowUUID) {
24-
let shouldShowSection = LegacyFeatureFlagsManager.shared.isFeatureEnabled(.hntBookmarksSection,
25-
checking: .userOnly)
24+
let shouldShowSection = !LegacyFeatureFlagsManager.shared.isFeatureEnabled(.homepageStoriesRedesign,
25+
checking: .buildOnly)
2626
self.init(
2727
windowUUID: windowUUID,
2828
bookmarks: [],

firefox-ios/Client/Frontend/Home/Homepage Rebuild/HomepageDiffableDataSource.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ final class HomepageDiffableDataSource:
119119
snapshot.appendItems(stories, toSection: .pocket(textColor))
120120
}
121121

122-
if featureFlags.isFeatureEnabled(.hntCusomizationSection, checking: .buildOnly) {
122+
if !featureFlags.isFeatureEnabled(.homepageStoriesRedesign, checking: .buildOnly) {
123123
snapshot.appendSections([.customizeHomepage])
124124
snapshot.appendItems([.customizeHomepage], toSection: .customizeHomepage)
125125
}

firefox-ios/Client/Frontend/Home/Homepage Rebuild/JumpBackIn/JumpBackInSectionState.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ struct JumpBackInSectionState: StateType, Equatable, Hashable {
2727
windowUUID: WindowUUID
2828
) {
2929
// TODO: FXIOS-11412 / 11226 - Move profile dependency and show section also based on feature flags
30-
let shouldShowSection = LegacyFeatureFlagsManager.shared.isFeatureEnabled(.hntJumpBackInSection,
31-
checking: .userOnly)
30+
let shouldShowSection = !LegacyFeatureFlagsManager.shared.isFeatureEnabled(.homepageStoriesRedesign,
31+
checking: .buildOnly)
3232
self.init(
3333
windowUUID: windowUUID,
3434
jumpBackInTabs: [],

firefox-ios/Client/Frontend/Home/JumpBackIn/JumpBackInViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ extension JumpBackInViewModel: HomepageViewModelProtocol {
307307
}
308308

309309
var isEnabled: Bool {
310-
let isEnabled = featureFlags.isFeatureEnabled(.hntJumpBackInSection, checking: .userOnly)
310+
let isEnabled = !featureFlags.isFeatureEnabled(.homepageStoriesRedesign, checking: .buildOnly)
311311
return !isPrivate && isEnabled
312312
}
313313

firefox-ios/Client/Frontend/Settings/HomepageSettings/HomePageSettingViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class HomePageSettingViewController: SettingsTableViewController, FeatureFlaggab
128128
prefs: profile.prefs,
129129
theme: themeManager.getCurrentTheme(for: windowUUID),
130130
prefKey: PrefsKeys.FeatureFlags.JumpBackInSection,
131-
defaultValue: featureFlags.isFeatureEnabled(.hntJumpBackInSection, checking: .userOnly),
131+
defaultValue: !featureFlags.isFeatureEnabled(.homepageStoriesRedesign, checking: .buildOnly),
132132
titleText: .Settings.Homepage.CustomizeFirefoxHome.JumpBackIn
133133
) { value in
134134
store.dispatchLegacy(
@@ -145,7 +145,7 @@ class HomePageSettingViewController: SettingsTableViewController, FeatureFlaggab
145145
prefs: profile.prefs,
146146
theme: themeManager.getCurrentTheme(for: windowUUID),
147147
prefKey: PrefsKeys.FeatureFlags.BookmarksSection,
148-
defaultValue: featureFlags.isFeatureEnabled(.hntBookmarksSection, checking: .userOnly),
148+
defaultValue: !featureFlags.isFeatureEnabled(.homepageStoriesRedesign, checking: .buildOnly),
149149
titleText: .Settings.Homepage.CustomizeFirefoxHome.Bookmarks
150150
) { value in
151151
store.dispatchLegacy(

firefox-ios/Client/Nimbus/NimbusFeatureFlagLayer.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,9 @@ final class NimbusFeatureFlagLayer {
4141
case .feltPrivacySimplifiedUI, .feltPrivacyFeltDeletion:
4242
return checkFeltPrivacyFeature(for: featureID, from: nimbus)
4343

44-
case .hntBookmarksSection:
45-
return checkHNTBookmarksSectionFeature(from: nimbus)
46-
4744
case .hntContentFeedRefresh:
4845
return checkHNTContentFeedRefreshFeature(from: nimbus)
4946

50-
case .hntCusomizationSection:
51-
return checkHNTCustomizationSectionFeature(from: nimbus)
52-
53-
case .hntJumpBackInSection:
54-
return checkHNTJumpBackInSectionFeature(from: nimbus)
55-
5647
case .hntSponsoredShortcuts:
5748
return checkHNTSponsoredShortcutsFeature(from: nimbus)
5849

@@ -206,22 +197,10 @@ final class NimbusFeatureFlagLayer {
206197
}
207198
}
208199

209-
private func checkHNTBookmarksSectionFeature(from nimbus: FxNimbus) -> Bool {
210-
return nimbus.features.hntBookmarksSectionFeature.value().enabled
211-
}
212-
213200
private func checkHNTContentFeedRefreshFeature(from nimbus: FxNimbus) -> Bool {
214201
return nimbus.features.hntContentFeedCleanupFeature.value().enabled
215202
}
216203

217-
private func checkHNTCustomizationSectionFeature(from nimbus: FxNimbus) -> Bool {
218-
return nimbus.features.hntCustomizationSectionFeature.value().enabled
219-
}
220-
221-
private func checkHNTJumpBackInSectionFeature(from nimbus: FxNimbus) -> Bool {
222-
return nimbus.features.hntJumpBackInSectionFeature.value().enabled
223-
}
224-
225204
private func checkHNTSponsoredShortcutsFeature(from nimbus: FxNimbus) -> Bool {
226205
return nimbus.features.hntSponsoredShortcutsFeature.value().enabled
227206
}

firefox-ios/Client/Telemetry/TelemetryWrapper.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,10 @@ class TelemetryWrapper: TelemetryWrapperProtocol, FeatureFlaggable {
305305
}
306306

307307
// Homepage section preferences
308-
let isJumpBackInEnabled = featureFlags.isFeatureEnabled(.hntJumpBackInSection, checking: .userOnly)
308+
let isJumpBackInEnabled = !featureFlags.isFeatureEnabled(.homepageStoriesRedesign, checking: .buildOnly)
309309
GleanMetrics.Preferences.jumpBackIn.set(isJumpBackInEnabled)
310310

311-
let isBookmarksEnabled = featureFlags.isFeatureEnabled(.hntBookmarksSection, checking: .userOnly)
311+
let isBookmarksEnabled = !featureFlags.isFeatureEnabled(.homepageStoriesRedesign, checking: .buildOnly)
312312
GleanMetrics.Preferences.recentlySaved.set(isBookmarksEnabled)
313313

314314
let isFeatureEnabled = prefs.boolForKey(PrefsKeys.UserFeatureFlagPrefs.ASPocketStories) ?? true

firefox-ios/firefox-ios-tests/Tests/ClientTests/Frontend/Homepage Rebuild/HomepageDiffableDataSourceTests.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class HomepageDiffableDataSourceTests: XCTestCase {
3535

3636
// MARK: - applyInitialSnapshot
3737
func test_updateSnapshot_hasCorrectData() throws {
38-
setupNimbusHNTCustomizationSectionTesting(isEnabled: true)
38+
setupNimbusHomepageRedesignTesting(storiesRedesignEnabled: false)
3939
let dataSource = try XCTUnwrap(diffableDataSource)
4040

4141
dataSource.updateSnapshot(
@@ -90,7 +90,7 @@ final class HomepageDiffableDataSourceTests: XCTestCase {
9090
}
9191

9292
func test_updateSnapshot_withValidState_returnTopSites() throws {
93-
setupNimbusHNTCustomizationSectionTesting(isEnabled: true)
93+
setupNimbusHomepageRedesignTesting(storiesRedesignEnabled: false)
9494
let dataSource = try XCTUnwrap(diffableDataSource)
9595

9696
let state = HomepageState.reducer(
@@ -123,7 +123,7 @@ final class HomepageDiffableDataSourceTests: XCTestCase {
123123
}
124124

125125
func test_updateSnapshot_withValidState_returnPocketStories() throws {
126-
setupNimbusHNTCustomizationSectionTesting(isEnabled: true)
126+
setupNimbusHomepageRedesignTesting(storiesRedesignEnabled: false)
127127
let dataSource = try XCTUnwrap(diffableDataSource)
128128

129129
let state = HomepageState.reducer(
@@ -147,7 +147,7 @@ final class HomepageDiffableDataSourceTests: XCTestCase {
147147
}
148148

149149
func test_updateSnapshot_withValidState_returnMessageCard() throws {
150-
setupNimbusHNTCustomizationSectionTesting(isEnabled: true)
150+
setupNimbusHomepageRedesignTesting(storiesRedesignEnabled: false)
151151
let dataSource = try XCTUnwrap(diffableDataSource)
152152
let configuration = MessageCardConfiguration(
153153
title: "Example Title",
@@ -177,7 +177,7 @@ final class HomepageDiffableDataSourceTests: XCTestCase {
177177
}
178178

179179
func test_updateSnapshot_withValidState_returnBookmarks() throws {
180-
setupNimbusHNTCustomizationSectionTesting(isEnabled: true)
180+
setupNimbusHomepageRedesignTesting(storiesRedesignEnabled: false)
181181
let dataSource = try XCTUnwrap(diffableDataSource)
182182

183183
let state = HomepageState.reducer(
@@ -207,7 +207,7 @@ final class HomepageDiffableDataSourceTests: XCTestCase {
207207
}
208208

209209
func test_updateSnapshot_withValidState_returnJumpBackInSection() throws {
210-
setupNimbusHNTCustomizationSectionTesting(isEnabled: true)
210+
setupNimbusHomepageRedesignTesting(storiesRedesignEnabled: false)
211211
let dataSource = try XCTUnwrap(diffableDataSource)
212212

213213
let state = HomepageState.reducer(
@@ -230,8 +230,8 @@ final class HomepageDiffableDataSourceTests: XCTestCase {
230230
XCTAssertEqual(snapshot.sectionIdentifiers, expectedSections)
231231
}
232232

233-
func test_cusomizationSectionFlagEnabled_returnsExpectedSections() throws {
234-
setupNimbusHNTCustomizationSectionTesting(isEnabled: true)
233+
func test_customizationSectionShown_returnsExpectedSections() throws {
234+
setupNimbusHomepageRedesignTesting(storiesRedesignEnabled: false)
235235

236236
let dataSource = try XCTUnwrap(diffableDataSource)
237237
let state = HomepageState(windowUUID: .XCTestDefaultUUID)
@@ -243,8 +243,8 @@ final class HomepageDiffableDataSourceTests: XCTestCase {
243243
XCTAssertEqual(snapshot.sectionIdentifiers, expectedSections)
244244
}
245245

246-
func test_customizationSectionFlagDisabled_returnsExpectedSections() throws {
247-
setupNimbusHNTCustomizationSectionTesting(isEnabled: false)
246+
func test_customizationSectionHidden_returnsExpectedSections() throws {
247+
setupNimbusHomepageRedesignTesting(storiesRedesignEnabled: true)
248248

249249
let dataSource = try XCTUnwrap(diffableDataSource)
250250
let state = HomepageState(windowUUID: .XCTestDefaultUUID)
@@ -294,10 +294,10 @@ final class HomepageDiffableDataSourceTests: XCTestCase {
294294
return tab
295295
}
296296

297-
private func setupNimbusHNTCustomizationSectionTesting(isEnabled: Bool) {
298-
FxNimbus.shared.features.hntCustomizationSectionFeature.with { _, _ in
299-
return HntCustomizationSectionFeature(
300-
enabled: isEnabled
297+
private func setupNimbusHomepageRedesignTesting(storiesRedesignEnabled: Bool) {
298+
FxNimbus.shared.features.homepageRedesignFeature.with { _, _ in
299+
return HomepageRedesignFeature(
300+
storiesRedesign: storiesRedesignEnabled
301301
)
302302
}
303303
}

0 commit comments

Comments
 (0)