Skip to content

Commit 9ec7073

Browse files
committed
Recover search status back from the password detail
1 parent 5a91db4 commit 9ec7073

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pass/Controllers/PasswordNavigationViewController.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class PasswordNavigationViewController: UIViewController {
3232

3333
var viewingUnsyncedPasswords = false
3434
var tapTabBarTime: TimeInterval = 0
35+
var searchText: String?
3536

3637
lazy var passwordManager = PasswordManager(viewController: self)
3738

@@ -109,6 +110,16 @@ class PasswordNavigationViewController: UIViewController {
109110
configureNavigationBar()
110111
}
111112

113+
override func viewDidAppear(_ animated: Bool) {
114+
super.viewDidAppear(animated)
115+
if searchText != nil {
116+
DispatchQueue.main.async {
117+
self.searchBar.text = self.searchText
118+
self.searchController.isActive = true
119+
}
120+
}
121+
}
122+
112123
private func configureSearchBar() {
113124
if Defaults.isShowFolderOn {
114125
searchBar.scopeButtonTitles = SearchBarScope.allCases.map(\.localizedName)
@@ -388,6 +399,7 @@ extension PasswordNavigationViewController {
388399

389400
extension PasswordNavigationViewController: UISearchBarDelegate {
390401
func search(matching text: String) {
402+
searchText = text
391403
dataSource?.showTableEntries(matching: text)
392404
tableView.reloadData()
393405
}
@@ -414,6 +426,7 @@ extension PasswordNavigationViewController: UISearchBarDelegate {
414426
searchBar.selectedScopeButtonIndex = SearchBarScope.current.rawValue
415427
}
416428
activateSearch(searchBar.selectedScopeButtonIndex)
429+
search(matching: searchBar.text ?? "")
417430
}
418431

419432
func searchBar(_: UISearchBar, textDidChange searchText: String) {
@@ -431,6 +444,7 @@ extension PasswordNavigationViewController: UISearchBarDelegate {
431444
func cancelSearch() {
432445
configureTableView(in: parentPasswordEntity)
433446
dataSource?.isSearchActive = false
447+
searchText = nil
434448
tableView.reloadData()
435449
}
436450
}

0 commit comments

Comments
 (0)