Skip to content

Commit

Permalink
Fix autofill search authentication looping (#3598)
Browse files Browse the repository at this point in the history
<!--
Note: This checklist is a reminder of our shared engineering
expectations. Feel free to change it, although assigning a GitHub
reviewer and the items in bold are required.

⚠️ If you're an external contributor, please file an issue first before
working on a PR, as we can't guarantee that we will accept your changes
if they haven't been discussed ahead of time. Thanks!
-->

Task/Issue URL:
https://app.asana.com/0/1203822806345703/1208755477452311/f
Tech Design URL:
CC:

**Description**:
Fixes an issue where if the Passwords screen is dismissed while in
search mode, UISearchController prevented the Passwords screen from
being released from memory. I’ve also found and fixed a memory leak with
the autofill breakage reporter.
  • Loading branch information
amddg44 authored Nov 20, 2024
1 parent 6642b4b commit 4876918
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions DuckDuckGo/AutofillLoginSettingsListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ final class AutofillLoginSettingsListViewController: UIViewController {
super.viewDidLoad()
title = UserText.autofillLoginListTitle
extendedLayoutIncludesOpaqueBars = true
navigationController?.presentationController?.delegate = self
setupCancellables()
installSubviews()
installConstraints()
Expand Down Expand Up @@ -449,6 +450,11 @@ final class AutofillLoginSettingsListViewController: UIViewController {
}
}

private func dismissSearchIfRequired() {
guard searchController.isActive else { return }
searchController.dismiss(animated: false)
}

private func presentDeleteConfirmation(for title: String, domain: String) {
let message = title.isEmpty ? UserText.autofillLoginListLoginDeletedToastMessageNoTitle
: UserText.autofillLoginListLoginDeletedToastMessage(for: title)
Expand Down Expand Up @@ -805,11 +811,11 @@ final class AutofillLoginSettingsListViewController: UIViewController {
let cell = tableView.dequeueCell(ofType: AutofillBreakageReportTableViewCell.self, for: indexPath)
let contentView = AutofillBreakageReportCellContentView(onReport: { [weak self] in

guard let alert = self?.viewModel.createBreakageReporterAlert() else {
guard let self = self, let alert = self.viewModel.createBreakageReporterAlert() else {
return
}

self?.present(controller: alert, fromView: tableView)
self.present(controller: alert, fromView: self.tableView)

Pixel.fire(pixel: .autofillLoginsReportConfirmationPromptDisplayed)
})
Expand Down Expand Up @@ -1125,6 +1131,16 @@ extension AutofillLoginSettingsListViewController: UISearchBarDelegate {
}
}

// MARK: UIAdaptivePresentationControllerDelegate

extension AutofillLoginSettingsListViewController: UIAdaptivePresentationControllerDelegate {

func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
dismissSearchIfRequired()
}

}

// MARK: Keyboard

extension AutofillLoginSettingsListViewController {
Expand Down

0 comments on commit 4876918

Please sign in to comment.