use index functions instead of counters
This commit is contained in:
parent
80314e766f
commit
c12c6b90f5
|
@ -178,36 +178,34 @@ func processWindowsForTabs(wins: [SFSafariWindow], options: TabQueryOptions?, co
|
||||||
}
|
}
|
||||||
var newTabs: [Tab] = []
|
var newTabs: [Tab] = []
|
||||||
let winGroup = DispatchGroup()
|
let winGroup = DispatchGroup()
|
||||||
var windowIndex = 0
|
|
||||||
for win in wins {
|
for win in wins {
|
||||||
winGroup.enter()
|
winGroup.enter()
|
||||||
win.getActiveTab { activeTab in
|
win.getActiveTab { activeTab in
|
||||||
win.getAllTabs { allTabs in
|
win.getAllTabs { allTabs in
|
||||||
let tabGroup = DispatchGroup()
|
let tabGroup = DispatchGroup()
|
||||||
var tabIndex = 0
|
|
||||||
for tab in allTabs {
|
for tab in allTabs {
|
||||||
tabGroup.enter()
|
tabGroup.enter()
|
||||||
if options?.active ?? false {
|
if options?.active ?? false {
|
||||||
if activeTab != nil && activeTab == tab {
|
if activeTab != nil && activeTab == tab {
|
||||||
|
let windowIndex = wins.firstIndex(of: win) ?? -100
|
||||||
|
let tabIndex = allTabs.firstIndex(of: tab) ?? -1
|
||||||
makeTabObject(tab: tab, activeTab: activeTab, windowIndex: windowIndex, tabIndex: tabIndex, complete: { t in
|
makeTabObject(tab: tab, activeTab: activeTab, windowIndex: windowIndex, tabIndex: tabIndex, complete: { t in
|
||||||
newTabs.append(t)
|
newTabs.append(t)
|
||||||
tabIndex = tabIndex + 1
|
|
||||||
tabGroup.leave()
|
tabGroup.leave()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
tabIndex = tabIndex + 1
|
|
||||||
tabGroup.leave()
|
tabGroup.leave()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
let windowIndex = wins.firstIndex(of: win) ?? -100
|
||||||
|
let tabIndex = allTabs.firstIndex(of: tab) ?? -1
|
||||||
makeTabObject(tab: tab, activeTab: activeTab, windowIndex: windowIndex, tabIndex: tabIndex, complete: { t in
|
makeTabObject(tab: tab, activeTab: activeTab, windowIndex: windowIndex, tabIndex: tabIndex, complete: { t in
|
||||||
newTabs.append(t)
|
newTabs.append(t)
|
||||||
tabIndex = tabIndex + 1
|
|
||||||
tabGroup.leave()
|
tabGroup.leave()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tabGroup.notify(queue: .main) {
|
tabGroup.notify(queue: .main) {
|
||||||
windowIndex = windowIndex + 1
|
|
||||||
winGroup.leave()
|
winGroup.leave()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue