Skip to content

Commit

Permalink
Fix crash when quickly adding/removing tabs in switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
dus7 committed Apr 17, 2024
1 parent bcc849a commit 2d82935
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions DuckDuckGo/TabSwitcherViewController+KeyCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ extension TabSwitcherViewController {
}

@objc func keyboardNewTab() {
guard !isProcessingUpdates else { return }
delegate?.tabSwitcherDidRequestNewTab(tabSwitcher: self)
dismiss()
}
Expand Down
3 changes: 2 additions & 1 deletion DuckDuckGo/TabSwitcherViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -278,6 +278,7 @@ class TabSwitcherViewController: UIViewController {
}

@IBAction func onAddPressed(_ sender: UIBarButtonItem) {
guard !isProcessingUpdates else { return }
delegate.tabSwitcherDidRequestNewTab(tabSwitcher: self)
dismiss()
}
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/TabViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
}

Expand Down

0 comments on commit 2d82935

Please sign in to comment.