Skip to content

Commit

Permalink
Rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
afterxleep committed Oct 27, 2023
1 parent 5fa2229 commit 4cfb5e5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions DuckDuckGo/NavigationBar/View/HomeButtonMenuFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ struct HomeButtonMenuFactory {
let item = NSMenuItem(title: UserText.mainMenuHomeButton)

let isButtonVisible = LocalPinningManager.shared.isPinned(.homeButton)
let buttonPosition = AppearancePreferences.shared.homeButtonposition
let buttonPosition = AppearancePreferences.shared.homeButtonPosition

let hiddenItem: NSMenuItem = BlockMenuItem(title: UserText.mainMenuHomeButton(for: .hidden), isChecked: !isButtonVisible, block: {
AppearancePreferences.shared.homeButtonposition = .hidden
AppearancePreferences.shared.homeButtonPosition = .hidden
LocalPinningManager.shared.unpin(.homeButton)
})
let leftItem: NSMenuItem = BlockMenuItem(title: UserText.mainMenuHomeButton(for: .left), isChecked: isButtonVisible && buttonPosition == .left, block: {
AppearancePreferences.shared.homeButtonposition = .left
AppearancePreferences.shared.homeButtonPosition = .left
LocalPinningManager.shared.unpin(.homeButton)
LocalPinningManager.shared.pin(.homeButton)
})
let rightItem: NSMenuItem = BlockMenuItem(title: UserText.mainMenuHomeButton(for: .right), isChecked: isButtonVisible && buttonPosition == .right, block: {
AppearancePreferences.shared.homeButtonposition = .right
AppearancePreferences.shared.homeButtonPosition = .right
LocalPinningManager.shared.unpin(.homeButton)
LocalPinningManager.shared.pin(.homeButton)
})
Expand Down
8 changes: 4 additions & 4 deletions DuckDuckGo/Preferences/Model/AppearancePreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ final class AppearancePreferences: ObservableObject {
}
}

@Published var homeButtonposition: HomeButtonPosition {
@Published var homeButtonPosition: HomeButtonPosition {
didSet {
persistor.homeButtonPosition = homeButtonposition
switch homeButtonposition {
persistor.homeButtonPosition = homeButtonPosition
switch homeButtonPosition {
case .hidden:
Pixel.fire(.homeButtonHidden)
case .left:
Expand Down Expand Up @@ -248,7 +248,7 @@ final class AppearancePreferences: ObservableObject {
defaultPageZoom = .init(rawValue: persistor.defaultPageZoom) ?? .percent100
showBookmarksBar = persistor.showBookmarksBar
bookmarksBarAppearance = persistor.bookmarksBarAppearance
homeButtonposition = persistor.homeButtonPosition
homeButtonPosition = persistor.homeButtonPosition
}

private var persistor: AppearancePreferencesPersistor
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/Preferences/Model/StartupPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ final class StartupPreferences: ObservableObject {
}

func updateHomeButton() {
persistor.appearancePrefs.homeButtonposition = homeButtonPosition
persistor.appearancePrefs.homeButtonPosition = homeButtonPosition
if homeButtonPosition != .hidden {
pinningManager.unpin(.homeButton)
pinningManager.pin(.homeButton)
Expand All @@ -115,7 +115,7 @@ final class StartupPreferences: ObservableObject {
}

private func updateHomeButtonState() {
homeButtonPosition = pinningManager.isPinned(.homeButton) ? persistor.appearancePrefs.homeButtonposition : .hidden
homeButtonPosition = pinningManager.isPinned(.homeButton) ? persistor.appearancePrefs.homeButtonPosition : .hidden
}

private func listenToPinningManagerNotifications() {
Expand Down
4 changes: 2 additions & 2 deletions UnitTests/Preferences/AppearancePreferencesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ final class AppearancePreferencesTests: XCTestCase {
XCTAssertEqual(model.isFavoriteVisible, true)
XCTAssertEqual(model.isContinueSetUpVisible, true)
XCTAssertEqual(model.isRecentActivityVisible, true)
XCTAssertEqual(model.homeButtonposition, .left)
XCTAssertEqual(model.homeButtonPosition, .left)

model = AppearancePreferences(
persistor: AppearancePreferencesPersistorMock(
Expand All @@ -100,7 +100,7 @@ final class AppearancePreferencesTests: XCTestCase {
XCTAssertEqual(model.isFavoriteVisible, false)
XCTAssertEqual(model.isContinueSetUpVisible, false)
XCTAssertEqual(model.isRecentActivityVisible, false)
XCTAssertEqual(model.homeButtonposition, .left)
XCTAssertEqual(model.homeButtonPosition, .left)
}

func testWhenInitializedWithGarbageThenThemeIsSetToSystemDefault() throws {
Expand Down

0 comments on commit 4cfb5e5

Please sign in to comment.