Remote tabs: Fix bug where menu was out of sync with list of tabs
This commit is contained in:
@@ -140,12 +140,9 @@ class TabPickerViewController: UIViewController, UICollectionViewDelegate
|
||||
}
|
||||
|
||||
public func setTabInfos(_ infos: [TabInfo], forHost host: String) {
|
||||
let wasEmpty = tabIdentifiersByHost.isEmpty
|
||||
tabIdentifiersByHost[host] = infos
|
||||
|
||||
if wasEmpty {
|
||||
selectedTabHost = host
|
||||
} else if host == selectedTabHost {
|
||||
if host == selectedTabHost {
|
||||
var snapshot = dataSource.snapshot()
|
||||
snapshot.deleteAllItems()
|
||||
snapshot.appendSections([ 0 ])
|
||||
@@ -165,6 +162,10 @@ class TabPickerViewController: UIViewController, UICollectionViewDelegate
|
||||
}
|
||||
|
||||
hostPickerButton.menu = UIMenu(children: menuChildren)
|
||||
|
||||
// Update list for whatever the selected item is
|
||||
selectedTabHost = hostPickerButton.menu?.selectedElements.first?.title
|
||||
|
||||
if tabIdentifiersByHost.keys.count > 0 && tabIdentifiersByHost.keys.first != Self.localHostIdentifier {
|
||||
navigationItem.titleView = hostPickerButton
|
||||
} else {
|
||||
@@ -201,7 +202,7 @@ class TabPickerViewController: UIViewController, UICollectionViewDelegate
|
||||
}
|
||||
|
||||
private func didChangeSelectedTabHost(_ tabHost: String) {
|
||||
guard let tabIdentifiers = tabIdentifiersByHost[tabHost] else { return }
|
||||
guard let tabIdentifiers = tabIdentifiersByHost[tabHost] else { fatalError() }
|
||||
|
||||
var snapshot = dataSource.snapshot()
|
||||
snapshot.deleteAllItems()
|
||||
|
||||
Reference in New Issue
Block a user