Skip to content

Commit

Permalink
Fix undo all tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
OrlaM committed Mar 1, 2024
1 parent 24a5186 commit e64fc13
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion firefox-ios/Client/TabManagement/Legacy/LegacyTabManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -647,17 +647,26 @@ class LegacyTabManager: NSObject, FeatureFlaggable, TabManager, TabEventHandler
@MainActor
func removeAllTabs(isPrivateMode: Bool) async {
let currentModeTabs = tabs.filter { $0.isPrivate == isPrivateMode }
backupCloseTabs = currentModeTabs
if let tab = selectedTab, tab.isPrivate == isPrivateMode {
backupCloseTab = BackupCloseTab(tab: tab,
restorePosition: tabs.firstIndex(of: tab))
}
backupCloseTabs = tabs
for tab in currentModeTabs {
await self.removeTab(tab.tabUUID)
}
storeChanges()
}

func undoCloseAllTabs() {
guard !backupCloseTabs.isEmpty else { return }
tabs = backupCloseTabs
storeChanges()
backupCloseTabs = [Tab]()
if backupCloseTab != nil {
selectTab(backupCloseTab?.tab)
backupCloseTab = nil
}
}

@MainActor
Expand Down

0 comments on commit e64fc13

Please sign in to comment.