mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
get proper tab index on makeSenderTabObject
This commit is contained in:
parent
c99403255d
commit
b912470e69
@ -13,7 +13,9 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
|||||||
page.getPropertiesWithCompletionHandler { properties in
|
page.getPropertiesWithCompletionHandler { properties in
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
makeSenderTabObject(page: page, props: properties, complete: { senderTab in
|
makeSenderTabObject(page: page, props: properties, complete: { senderTab in
|
||||||
|
DispatchQueue.main.async {
|
||||||
self.sendMessage(msg: userInfo, sender: senderTab)
|
self.sendMessage(msg: userInfo, sender: senderTab)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,15 +74,8 @@ func makeSenderTabObject(page: SFSafariPage, props: SFSafariPageProperties?, com
|
|||||||
t.active = activeTab != nil && tab == activeTab
|
t.active = activeTab != nil && tab == activeTab
|
||||||
SFSafariApplication.getAllWindows(completionHandler: { allWins in
|
SFSafariApplication.getAllWindows(completionHandler: { allWins in
|
||||||
t.windowId = allWins.firstIndex(of: win!) ?? -100
|
t.windowId = allWins.firstIndex(of: win!) ?? -100
|
||||||
let winGroup = DispatchGroup()
|
win!.getAllTabs { allWinTabs in
|
||||||
for allWin in allWins {
|
|
||||||
winGroup.enter()
|
|
||||||
allWin.getAllTabs { allWinTabs in
|
|
||||||
t.index = allWinTabs.firstIndex(of: tab) ?? -1
|
t.index = allWinTabs.firstIndex(of: tab) ?? -1
|
||||||
winGroup.leave()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
winGroup.notify(queue: .main) {
|
|
||||||
t.id = "\(t.windowId)_\(t.index)"
|
t.id = "\(t.windowId)_\(t.index)"
|
||||||
complete(t)
|
complete(t)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user