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

Conversation

PARAIPAN9
Copy link
Collaborator

@PARAIPAN9 PARAIPAN9 commented Nov 6, 2023

📜 Tickets

Jira ticket
Github issue

💡 Description

Changes in this PR:

  • I've noticed that the 'urlBarPresentCFR' is being called multiple times, leading to the creation of multiple 'contextualVCs.' This not only disrupts the logic but also causes memory leaks. Ensuring that we work with the same reference can help us avoid redundant calls to the 'canPresent' method in 'ContextualHintEligibilityUtility,' thereby preventing user prefs issues and memory leaks.

  • Additionally, after the second 'CFR' is displayed, I reset the timestamp. Otherwise, if 24 hours have passed, two 'CFRs' might appear consecutively.

📝 Checklist

You have to check all boxes before merging

  • Filled in the above information (tickets numbers and description of your work)
  • Updated the PR name to follow our PR naming guidelines
  • Wrote unit tests and/or ensured the tests suite is passing
  • When working on UI, I checked and implemented accessibility (minimum Dynamic Text and VoiceOver)
  • If needed I updated documentation / comments for complex code and public methods

@PARAIPAN9 PARAIPAN9 requested a review from a team as a code owner November 6, 2023 14:35
Client/Frontend/Browser/BrowserViewController.swift Outdated Show resolved Hide resolved
@@ -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?

@PARAIPAN9
Copy link
Collaborator Author

It was discovered that on smaller devices like the iPhone SE, the action button label would go to the next line, even though there was enough space on one line. After investigating, I found that the resizable button was causing layout problems. Therefore, I changed the button to a UIButton using configuration, and it fixed the issue.

Before After
before after

@lmarceau
Copy link
Contributor

lmarceau commented Nov 9, 2023

Just wanna say LGTM from my side for the comments I made

@@ -75,6 +77,18 @@ public class ContextualHintView: UIView, ThemeApplicable {
public func configure(viewModel: ContextualHintViewModel) {
self.viewModel = viewModel

let actionButtonViewModel = LinkButtonViewModel(
title: viewModel.actionButtonTitle,
a11yIdentifier: "",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please add an a11y id here?

let actionButtonViewModel = LinkButtonViewModel(
title: viewModel.actionButtonTitle,
a11yIdentifier: "",
contentInsets: NSDirectionalEdgeInsets(
Copy link
Contributor

Choose a reason for hiding this comment

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

The contentInsets should be defined in the UX struct.

@mobiletest-ci-bot
Copy link

Messages
📖 Project coverage: 33.84%
📖 Edited 9 files
📖 Created 0 files

Client.app: Coverage: 32.6

File Coverage
BrowserViewController+URLBarDelegate.swift 2.38% ⚠️
ContextualHintViewController.swift 7.35% ⚠️
BrowserViewController.swift 16.15% ⚠️
ContextualHintEligibilityUtility.swift 95.05%

WidgetKitExtension.appex: Coverage: 23.17

File Coverage
TimeConstants.swift 71.95%

Generated by 🚫 Danger Swift against 5ece51e

@thatswinnie thatswinnie merged commit 7d43a40 into mozilla-mobile:main Nov 9, 2023
10 checks passed
@thatswinnie
Copy link
Contributor

@Mergifyio backport release/v120

Copy link
Contributor

mergify bot commented Nov 9, 2023

backport release/v120

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Nov 9, 2023
* Use one instance for the shopping CFR

* Rename contextHintVC and add new unit test

* Initialize shopping contextual hint in init of BVC

* Fix crash that can happen when manually changing time on the device

* Fix stackview layout by using UIButton configuration

* Change UIButton to LinkButton

* Remove configuration from actionButton

* Add a11y id and move button insets to UX struct

---------

Co-authored-by: Winnie Teichmann <[email protected]>
(cherry picked from commit 7d43a40)
thatswinnie pushed a commit that referenced this pull request Nov 9, 2023
* Use one instance for the shopping CFR

* Rename contextHintVC and add new unit test

* Initialize shopping contextual hint in init of BVC

* Fix crash that can happen when manually changing time on the device

* Fix stackview layout by using UIButton configuration

* Change UIButton to LinkButton

* Remove configuration from actionButton

* Add a11y id and move button insets to UX struct

---------

Co-authored-by: Winnie Teichmann <[email protected]>
(cherry picked from commit 7d43a40)

Co-authored-by: PARAIPAN SORIN <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants