Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor FXIOS-10855 #23671 Reenable rating prompt with different rules (backport #24253) #24272

Open
wants to merge 3 commits into
base: release/v135
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions firefox-ios/Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1048,8 +1048,6 @@
8ADC2A212A3399DC00543DAA /* YourRightsSetting.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ADC2A202A3399DC00543DAA /* YourRightsSetting.swift */; };
8ADEC6832A40F208002D2ED8 /* AppSettingsTableViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ADEC6822A40F208002D2ED8 /* AppSettingsTableViewControllerTests.swift */; };
8ADED7EC27691351009C19E6 /* CalendarExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ADED7EB27691351009C19E6 /* CalendarExtensionsTests.swift */; };
8ADED7EE276A7750009C19E6 /* CumulativeDaysOfUseCounter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ADED7ED276A7750009C19E6 /* CumulativeDaysOfUseCounter.swift */; };
8ADED7F0276A7788009C19E6 /* CumulativeDaysOfUseCounterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ADED7EF276A7788009C19E6 /* CumulativeDaysOfUseCounterTests.swift */; };
8AE0BF4F2819B10E00F33EC4 /* TopSitesSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AE0BF4E2819B10E00F33EC4 /* TopSitesSettingsViewController.swift */; };
8AE1E1CB27B18F560024C45E /* SearchBarSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AE1E1CA27B18F560024C45E /* SearchBarSettingsViewController.swift */; };
8AE1E1CD27B191110024C45E /* SearchBarSettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AE1E1CC27B191110024C45E /* SearchBarSettingsViewModel.swift */; };
Expand Down Expand Up @@ -7860,8 +7858,6 @@
8ADC2A202A3399DC00543DAA /* YourRightsSetting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YourRightsSetting.swift; sourceTree = "<group>"; };
8ADEC6822A40F208002D2ED8 /* AppSettingsTableViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSettingsTableViewControllerTests.swift; sourceTree = "<group>"; };
8ADED7EB27691351009C19E6 /* CalendarExtensionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarExtensionsTests.swift; sourceTree = "<group>"; };
8ADED7ED276A7750009C19E6 /* CumulativeDaysOfUseCounter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CumulativeDaysOfUseCounter.swift; sourceTree = "<group>"; };
8ADED7EF276A7788009C19E6 /* CumulativeDaysOfUseCounterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CumulativeDaysOfUseCounterTests.swift; sourceTree = "<group>"; };
8AE0BF4E2819B10E00F33EC4 /* TopSitesSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopSitesSettingsViewController.swift; sourceTree = "<group>"; };
8AE1E1CA27B18F560024C45E /* SearchBarSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBarSettingsViewController.swift; sourceTree = "<group>"; };
8AE1E1CC27B191110024C45E /* SearchBarSettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBarSettingsViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -11505,7 +11501,6 @@
8A1E3BE028CBAC1F003388C4 /* Utils */ = {
isa = PBXGroup;
children = (
8ADED7EF276A7788009C19E6 /* CumulativeDaysOfUseCounterTests.swift */,
8A13FA8E2AD83F00007527AB /* DefaultBackgroundTabLoaderTests.swift */,
961D6B822995AF84001B9CF1 /* GeneralizedImageFetcherTests.swift */,
C8E78BDC27F4A1E700C48BAA /* HistoryDeletionUtilityTests.swift */,
Expand Down Expand Up @@ -14033,7 +14028,6 @@
5AD3B67D2CF665AE00AFA1FE /* UIApplicationInterface.swift */,
5AD3B67B2CF65DE300AFA1FE /* LocaleInterface.swift */,
8A13FA8C2AD834FA007527AB /* BackgroundTabLoader.swift */,
8ADED7ED276A7750009C19E6 /* CumulativeDaysOfUseCounter.swift */,
C8BA0E7527F20B8E00DD8214 /* HistoryDeletionUtility.swift */,
C2296FCB2A601C190046ECA6 /* IntensityVisualEffectView.swift */,
F85C7F112721048E004BDBA4 /* Layout.swift */,
Expand Down Expand Up @@ -16351,7 +16345,6 @@
8AAAB0592C1B7240008830B3 /* MockRustFirefoxSuggest.swift in Sources */,
0BDDB33F2CA6B1F000D501DF /* EditFolderViewModel.swift in Sources */,
602B3D6729B0E1DB0066DEF8 /* ConversionValueUtil.swift in Sources */,
8ADED7EE276A7750009C19E6 /* CumulativeDaysOfUseCounter.swift in Sources */,
7AC7E0502C160FF800051D4D /* ReaderPanelEmptyStateView.swift in Sources */,
4346FF08295BA6A300F4D220 /* CreditCardSettingsViewController.swift in Sources */,
E19B38B528A42EBC00D8C541 /* WallpaperCellViewModel.swift in Sources */,
Expand Down Expand Up @@ -17391,7 +17384,6 @@
8A5189C92C1B614E00CDB668 /* SearchViewModelTests.swift in Sources */,
E1463D0629830E4F0074E16E /* MockUserNotificationCenter.swift in Sources */,
439B78182A09721600CAAE37 /* FormAutofillHelperTests.swift in Sources */,
8ADED7F0276A7788009C19E6 /* CumulativeDaysOfUseCounterTests.swift in Sources */,
8A7653C528A2E69100924ABF /* MockPocketAPI.swift in Sources */,
8A83B74A2A265044002FF9AC /* SettingsCoordinatorTests.swift in Sources */,
E1B9A2C42CADA78300F6A0E9 /* ToolbarTelemetryTests.swift in Sources */,
Expand Down
4 changes: 1 addition & 3 deletions firefox-ios/Client/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
)

lazy var themeManager: ThemeManager = DefaultThemeManager(sharedContainerIdentifier: AppInfo.sharedContainerIdentifier)
lazy var ratingPromptManager = RatingPromptManager(profile: profile)
lazy var appSessionManager: AppSessionProvider = AppSessionManager()
lazy var notificationSurfaceManager = NotificationSurfaceManager()
lazy var tabDataStore = DefaultTabDataStore()
Expand Down Expand Up @@ -163,10 +162,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
updateTopSitesWidget()

// Cleanup can be a heavy operation, take it out of the startup path. Instead check after a few seconds.
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) { [weak self] in
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
// TODO: testing to see if this fixes https://mozilla-hub.atlassian.net/browse/FXIOS-7632
// self?.profile.cleanupHistoryIfNeeded()
self?.ratingPromptManager.updateData()
}

DispatchQueue.global().async { [weak self] in
Expand Down
9 changes: 9 additions & 0 deletions firefox-ios/Client/Application/DefaultBrowserUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ struct DefaultBrowserUtil {
self.logger = logger
}

enum UserDefaultsKey: String {
case keyIsBrowserDefault = "com.moz.isBrowserDefault.key"
}

static var isBrowserDefault: Bool {
get { UserDefaults.standard.object(forKey: UserDefaultsKey.keyIsBrowserDefault.rawValue) as? Bool ?? false }
set { UserDefaults.standard.set(newValue, forKey: UserDefaultsKey.keyIsBrowserDefault.rawValue) }
}

func processUserDefaultState(isFirstRun: Bool) {
guard #available(iOS 18.2, *) else { return }

Expand Down
3 changes: 0 additions & 3 deletions firefox-ios/Client/Application/DependencyHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ class DependencyHelper {
let appSessionProvider: AppSessionProvider = appDelegate.appSessionManager
AppContainer.shared.register(service: appSessionProvider)

let ratingPromptManager: RatingPromptManager = appDelegate.ratingPromptManager
AppContainer.shared.register(service: ratingPromptManager)

let downloadQueue: DownloadQueue = appDelegate.appSessionManager.downloadQueue
AppContainer.shared.register(service: downloadQueue)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ final class RouteBuilder: FeatureFlaggable {
}
} else if urlScanner.isHTTPScheme {
TelemetryWrapper.gleanRecordEvent(category: .action, method: .open, object: .asDefaultBrowser)
RatingPromptManager.isBrowserDefault = true
DefaultBrowserUtil.isBrowserDefault = true
// Use the last browsing mode the user was in
return .search(url: url, isPrivate: isPrivate, options: [.focusLocationField])
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GleanPlumbContextProvider {
}

private var isDefaultBrowser: Bool {
return userDefaults.bool(forKey: RatingPromptManager.UserDefaultsKey.keyIsBrowserDefault.rawValue)
return userDefaults.bool(forKey: DefaultBrowserUtil.UserDefaultsKey.keyIsBrowserDefault.rawValue)
}

private var numberOfAppLaunches: Int32 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ class BrowserViewController: UIViewController,
tabManager: TabManager,
themeManager: ThemeManager = AppContainer.shared.resolve(),
notificationCenter: NotificationProtocol = NotificationCenter.default,
ratingPromptManager: RatingPromptManager = AppContainer.shared.resolve(),
downloadQueue: DownloadQueue = AppContainer.shared.resolve(),
logger: Logger = DefaultLogger.shared,
appAuthenticator: AppAuthenticationProtocol = AppAuthenticator()
Expand All @@ -281,7 +280,7 @@ class BrowserViewController: UIViewController,
self.tabManager = tabManager
self.themeManager = themeManager
self.notificationCenter = notificationCenter
self.ratingPromptManager = ratingPromptManager
self.ratingPromptManager = RatingPromptManager(prefs: profile.prefs)
self.readerModeCache = DiskReaderModeCache.sharedInstance
self.downloadQueue = downloadQueue
self.logger = logger
Expand Down Expand Up @@ -345,6 +344,9 @@ class BrowserViewController: UIViewController,
guard !AppEventQueue.activityIsCompleted(.browserUpdatedForAppActivation(tabWindowUUID)) else { return }
self?.browserDidBecomeActive()
}

ratingPromptManager.updateData()
ratingPromptManager.showRatingPromptIfNeeded()
}

@objc
Expand Down
Loading