Skip to content

Commit

Permalink
add debug menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
mallexxx committed Nov 15, 2024
1 parent e6cb52b commit 1689c1a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions DuckDuckGo/Menus/MainMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,11 @@ final class MainMenu: NSMenu {
NSMenuItem(title: "100 Tabs", action: #selector(MainViewController.addDebugTabs(_:)), representedObject: 100)
NSMenuItem(title: "150 Tabs", action: #selector(MainViewController.addDebugTabs(_:)), representedObject: 150)
}
NSMenuItem(title: "New Tab") {
NSMenuItem(title: "Reset Continue Setup", action: #selector(MainViewController.debugResetContinueSetup))
NSMenuItem(title: "Shift New Tab daily impression", action: #selector(MainViewController.debugShiftNewTabOpeningDate))
NSMenuItem(title: "Shift \(AppearancePreferences.Constants.dismissNextStepsCardsAfterDays) days", action: #selector(MainViewController.debugShiftNewTabOpeningDateNtimes))
}
}
NSMenuItem(title: "Skip Onboarding", action: #selector(MainViewController.skipOnboarding))
NSMenuItem(title: "Reset Data") {
Expand Down
18 changes: 18 additions & 0 deletions DuckDuckGo/Menus/MainMenuActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,24 @@ extension MainViewController {
}
}

@objc func debugResetContinueSetup(_ sender: Any?) {
AppearancePreferencesUserDefaultsPersistor().continueSetUpCardsLastDemonstrated = nil
AppearancePreferencesUserDefaultsPersistor().continueSetUpCardsNumberOfDaysDemonstrated = 0
AppearancePreferences.shared.isContinueSetUpCardsViewOutdated = false
AppearancePreferences.shared.isContinueSetUpVisible = true
}

@objc func debugShiftNewTabOpeningDate(_ sender: Any?) {
AppearancePreferencesUserDefaultsPersistor().continueSetUpCardsLastDemonstrated = (AppearancePreferencesUserDefaultsPersistor().continueSetUpCardsLastDemonstrated ?? Date()).addingTimeInterval(-.day)
AppearancePreferences.shared.continueSetUpCardsViewDidAppear()
}

@objc func debugShiftNewTabOpeningDateNtimes(_ sender: Any?) {
for _ in 0..<AppearancePreferences.Constants.dismissNextStepsCardsAfterDays {
debugShiftNewTabOpeningDate(sender)
}
}

@objc func resetDefaultBrowserPrompt(_ sender: Any?) {
UserDefaultsWrapper.clear(.defaultBrowserDismissed)
}
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Preferences/Model/AppearancePreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ final class AppearancePreferences: ObservableObject {
if let continueSetUpCardsLastDemonstrated = persistor.continueSetUpCardsLastDemonstrated {
// how many days has passed since last Continue Setup demonstration
let daysSinceLastDemonstration = Calendar.current.dateComponents([.day], from: continueSetUpCardsLastDemonstrated, to: dateTimeProvider()).day!
if daysSinceLastDemonstration > 0 || true {
if daysSinceLastDemonstration > 0 {
persistor.continueSetUpCardsLastDemonstrated = Date()
persistor.continueSetUpCardsNumberOfDaysDemonstrated += 1

Expand Down

0 comments on commit 1689c1a

Please sign in to comment.