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

Bugfix FXIOS-7646 [v120] The 3rd CFR is not displayed #17172

Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class BrowserViewController: UIViewController,
var overlayManager: OverlayModeManager
var appAuthenticator: AppAuthenticationProtocol
var contextHintVC: ContextualHintViewController
lmarceau marked this conversation as resolved.
Show resolved Hide resolved
var shoppingContextHintVC: ContextualHintViewController?
private var backgroundTabLoader: DefaultBackgroundTabLoader

// popover rotation handling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,38 @@ extension BrowserViewController: URLBarDelegate {
return
}

let contextualViewProvider = ContextualHintViewProvider(forHintType: .shoppingExperience,
with: profile)

let contextHintVC = ContextualHintViewController(with: contextualViewProvider)
if shoppingContextHintVC == nil {
configureShoppingContextVC(at: sourceView)
lmarceau marked this conversation as resolved.
Show resolved Hide resolved
} else {
shoppingContextHintVC = nil
}
}

contextHintVC.configure(
private func configureShoppingContextVC(at sourceView: UIView) {
let viewProvider = ContextualHintViewProvider(
forHintType: .shoppingExperience,
with: profile
)
shoppingContextHintVC = ContextualHintViewController(
with: viewProvider
)

guard let shoppingContextHintVC else { return }
shoppingContextHintVC.configure(
anchor: sourceView,
withArrowDirection: isBottomSearchBar ? .down : .up,
andDelegate: self,
presentedUsing: {
self.present(contextHintVC, animated: true)
TelemetryWrapper.recordEvent(category: .action,
method: .navigate,
object: .shoppingButton,
value: .shoppingCFRsDisplayed)
presentedUsing: { [unowned self] in
self.present(shoppingContextHintVC, animated: true)
TelemetryWrapper.recordEvent(
category: .action,
method: .navigate,
object: .shoppingButton,
value: .shoppingCFRsDisplayed
)
},
actionOnDismiss: {
self.shoppingContextHintVC = nil
},
andActionForButton: { [weak self] in
guard let self else { return }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ struct ContextualHintEligibilityUtility: ContextualHintEligibilityUtilityProtoco
if cfrCounter <= 2, !hasOptedIn, hasTimePassed {
// - Display CFR-1
profile.prefs.setInt(cfrCounter + 1, forKey: PrefsKeys.ContextualHints.shoppingOnboardingCFRsCounterKey.rawValue)
profile.prefs.setTimestamp(Date.now(), forKey: PrefsKeys.FakespotLastCFRTimestamp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the tests for canPresentShoppingCFR be adjusted to represent this new addition?

return true
} else if cfrCounter < 4, hasOptedIn, hasTimePassed {
// - Display CFR-2
Expand Down