Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Fix #2908: Selecting a single SE doesn't show up in quick search engine list #3037

Merged
merged 1 commit into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
23 changes: 12 additions & 11 deletions Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1131,28 +1131,29 @@ class BrowserViewController: UIViewController {
}

fileprivate func showSearchController() {
if searchController != nil {
return
}
if searchController != nil { return }

let tabType = TabType.of(tabManager.selectedTab)
searchController = SearchViewController(forTabType: tabType)
searchController!.searchEngines = profile.searchEngines
searchController!.searchDelegate = self
searchController!.profile = self.profile

guard let searchController = searchController else { return }

searchController.searchEngines = profile.searchEngines
searchController.searchDelegate = self
searchController.profile = self.profile

searchLoader = SearchLoader(profile: profile, topToolbar: topToolbar)
searchLoader?.addListener(searchController!)
searchLoader?.addListener(searchController)

addChild(searchController!)
view.addSubview(searchController!.view)
searchController!.view.snp.makeConstraints { make in
addChild(searchController)
view.addSubview(searchController.view)
searchController.view.snp.makeConstraints { make in
make.top.equalTo(self.topToolbar.snp.bottom)
make.left.right.bottom.equalTo(self.view)
return
}

searchController!.didMove(toParent: self)
searchController.didMove(toParent: self)
}

func updateTabsBarVisibility() {
Expand Down
9 changes: 8 additions & 1 deletion Client/Frontend/Browser/Search/SearchViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,15 @@ class SearchViewController: SiteTableViewController, KeyboardHelperDelegate, Loa
}

// If the user only has a single quick search engine, it is also their default one.
// In that case, we count it as if there are no quick suggestions to show.
// In that case, we count it as if there are no quick suggestions to show
// Unless Default Search Engine is different than Quick Search Engine
private var hasQuickSearchEngines: Bool {
let isDefaultEngineQuickEngine = searchEngines.defaultEngine().engineID == quickSearchEngines.first?.engineID

if quickSearchEngines.count == 1 {
return !isDefaultEngineQuickEngine
}

return quickSearchEngines.count > 1
}

Expand Down