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

Find in Page Hotfix + refactoring of forced unwrapping #450

Merged
merged 3 commits into from
Feb 28, 2022

Conversation

tomasstrba
Copy link
Contributor

Task/Issue URL: https://app.asana.com/0/1177771139624306/1201892459973519/f
CC: @brindy @sammacbeth

Description:
Find in Page doesn't work because there is a missing reference to findinpage user script in Tab instance

Steps to test this PR:

  1. Make sure find in page works
  2. Verify auto-consent feature works

Testing checklist:

  • Test with Release configuration

Internal references:

Software Engineering Expectations
Technical Design Template
When ready for review, remember to post the PR in MM

@tomasstrba tomasstrba requested review from brindy, sammacbeth and mallexxx and removed request for brindy, sammacbeth and mallexxx February 28, 2022 13:04
@tomasstrba tomasstrba changed the base branch from develop to release/0.19.0 February 28, 2022 13:10
Copy link
Contributor

@brindy brindy left a comment

Choose a reason for hiding this comment

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

LGTM! nice work removing the force unwraps too

@@ -109,20 +109,20 @@ final class AutoconsentUserScript: NSObject, UserScriptWithAutoconsent {
// push current privacy config settings to the background page
Self.background.updateSettings(settings: self.config.settings(for: .autoconsent))
let cmp = await Self.background.detectCmp(in: self.tabId)
guard cmp?.result == true else {
guard let cmp = cmp, cmp.result == true else {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sammacbeth, please, is the change here aligned with the auto-consent algorithm?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks fine to me, this won't change anything in the autoconsent behavior.

@@ -570,6 +570,7 @@ extension Tab: UserContentControllerDelegate {
userScripts.hoverUserScript.delegate = self
userScripts.autoconsentUserScript?.delegate = self

findInPageScript = userScripts.findInPageScript
attachFindInPage()
Copy link
Collaborator

@bwaresiak bwaresiak Feb 28, 2022

Choose a reason for hiding this comment

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

Wouldn't it be more clear to have attachFindInPage() take in FindInPageUserScript argument and set findInPageScript variable inside (along with model assignments etc). I looks like that is supposed to be transactional anyway. Alternatively didSet of findInPageScript could call that method.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, attaching the find in page is separate from the user script. see didSet of findInPage var. This is so that we can have different models per tab and show the correct find page state when switching tab.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No because attachFindInPage() is also called in didSet of weak var findInPage

Copy link
Collaborator

Choose a reason for hiding this comment

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

From what I see, we have different UserScripts instances per Tab, and same we do for FindInPageModel - so why not to guarantee these are always bound to each other?

Seeing how attachFindInPage() can be called on an optional user script may lead to inconsistency.

@@ -109,20 +109,20 @@ final class AutoconsentUserScript: NSObject, UserScriptWithAutoconsent {
// push current privacy config settings to the background page
Self.background.updateSettings(settings: self.config.settings(for: .autoconsent))
let cmp = await Self.background.detectCmp(in: self.tabId)
guard cmp?.result == true else {
guard let cmp = cmp, cmp.result == true else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks fine to me, this won't change anything in the autoconsent behavior.

@tomasstrba tomasstrba merged commit a726938 into release/0.19.0 Feb 28, 2022
@tomasstrba tomasstrba deleted the hotfix/tom/slow-find-in-page branch February 28, 2022 14:16
samsymons added a commit that referenced this pull request Mar 2, 2022
# By Tomas Strba (6) and others
# Via GitHub (1) and Tomas Strba (1)
* develop:
  Logins+ authentication (#438)
  Update privacy dashboard to main (#451)
  Version 0.19.1
  Remove mouse event listeners on browser close (#448)
  Find in Page Hotfix + refactoring of forced unwrapping (#450)
  Memory leak fixed (#449)
  Version 0.19.0
  Top autofill (#432)
  Option to add new notes or edit existing is disabled (#446)
  Use our own autoconsent fork (#444)
  New Feedback Form (#424)
  Update privacy dashboard (#440)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
#	DuckDuckGo/SecureVault/View/PasswordManager.storyboard
samsymons added a commit that referenced this pull request Mar 4, 2022
* develop:
  Logins+ authentication (#438)
  Update privacy dashboard to main (#451)
  Version 0.19.1
  Remove mouse event listeners on browser close (#448)
  Find in Page Hotfix + refactoring of forced unwrapping (#450)
  Memory leak fixed (#449)
  Version 0.19.0
  Top autofill (#432)
  Option to add new notes or edit existing is disabled (#446)
  Use our own autoconsent fork (#444)
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