diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index ad7c7a025f..b954c48d26 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -2245,7 +2245,7 @@ extension MainViewController: TabSwitcherButtonDelegate { } func showTabSwitcher() { - guard let currentTab = currentTab ?? tabManager.current(createIfNeeded: true) else { + guard currentTab ?? tabManager.current(createIfNeeded: true) != nil else { fatalError("Unable to get current tab") } diff --git a/DuckDuckGo/TabSwitcherViewController+KeyCommands.swift b/DuckDuckGo/TabSwitcherViewController+KeyCommands.swift index b28a30bb34..d3f867a00a 100644 --- a/DuckDuckGo/TabSwitcherViewController+KeyCommands.swift +++ b/DuckDuckGo/TabSwitcherViewController+KeyCommands.swift @@ -54,6 +54,7 @@ extension TabSwitcherViewController { } @objc func keyboardNewTab() { + guard !isProcessingUpdates else { return } delegate?.tabSwitcherDidRequestNewTab(tabSwitcher: self) dismiss() } diff --git a/DuckDuckGo/TabSwitcherViewController.swift b/DuckDuckGo/TabSwitcherViewController.swift index cb9b155f4e..86315bd1a7 100644 --- a/DuckDuckGo/TabSwitcherViewController.swift +++ b/DuckDuckGo/TabSwitcherViewController.swift @@ -71,7 +71,7 @@ class TabSwitcherViewController: UIViewController { var currentSelection: Int? private var tabSwitcherSettings: TabSwitcherSettings = DefaultTabSwitcherSettings() - private var isProcessingUpdates = false + private(set) var isProcessingUpdates = false private var canUpdateCollection = true let favicons = Favicons.shared @@ -278,6 +278,7 @@ class TabSwitcherViewController: UIViewController { } @IBAction func onAddPressed(_ sender: UIBarButtonItem) { + guard !isProcessingUpdates else { return } delegate.tabSwitcherDidRequestNewTab(tabSwitcher: self) dismiss() } diff --git a/DuckDuckGo/TabViewCell.swift b/DuckDuckGo/TabViewCell.swift index 0d98022045..0f848865c5 100644 --- a/DuckDuckGo/TabViewCell.swift +++ b/DuckDuckGo/TabViewCell.swift @@ -123,12 +123,12 @@ class TabViewCell: UICollectionViewCell { } private func startRemoveAnimation() { + self.isDeleting = true + self.deleteTab() UIView.animate(withDuration: 0.2, animations: { self.transform = CGAffineTransform.identity.translatedBy(x: -self.frame.width, y: 0) }, completion: { _ in self.isHidden = true - self.isDeleting = true - self.deleteTab() }) }