mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-07 09:31:31 +01:00
tab query fixes
This commit is contained in:
parent
d90279a596
commit
8bf6609c23
@ -41,7 +41,7 @@ export class BrowserApi {
|
|||||||
});
|
});
|
||||||
} else if (BrowserApi.isSafariApi) {
|
} else if (BrowserApi.isSafariApi) {
|
||||||
const tabs = await SafariApp.sendMessageToApp('tabs_query', JSON.stringify(options));
|
const tabs = await SafariApp.sendMessageToApp('tabs_query', JSON.stringify(options));
|
||||||
return tabs;
|
return tabs != null ? JSON.parse(tabs) : null;
|
||||||
// TODO
|
// TODO
|
||||||
/*
|
/*
|
||||||
if (options.currentWindow) {
|
if (options.currentWindow) {
|
||||||
|
@ -90,7 +90,7 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
|
|||||||
SFSafariApplication.getActiveWindow { (win) in
|
SFSafariApplication.getActiveWindow { (win) in
|
||||||
processWindowsForTabs(wins: [win!], options: options
|
processWindowsForTabs(wins: [win!], options: options
|
||||||
, complete: { (tabs) in
|
, complete: { (tabs) in
|
||||||
m!.data = jsonSerialize(obj: tabs)
|
m!.responseData = jsonSerialize(obj: tabs)
|
||||||
self.replyMessage(message: m!)
|
self.replyMessage(message: m!)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
|
|||||||
SFSafariApplication.getAllWindows { (wins) in
|
SFSafariApplication.getAllWindows { (wins) in
|
||||||
processWindowsForTabs(wins: wins, options: options
|
processWindowsForTabs(wins: wins, options: options
|
||||||
, complete: { (tabs) in
|
, complete: { (tabs) in
|
||||||
m!.data = jsonSerialize(obj: tabs)
|
m!.responseData = jsonSerialize(obj: tabs)
|
||||||
self.replyMessage(message: m!)
|
self.replyMessage(message: m!)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func processWindowsForTabs(wins: [SFSafariWindow], options: TabQueryOptions?, complete: ([Tab]) -> Void) {
|
func processWindowsForTabs(wins: [SFSafariWindow], options: TabQueryOptions?, complete: @escaping ([Tab]) -> Void) {
|
||||||
if(wins.count == 0) {
|
if(wins.count == 0) {
|
||||||
complete([])
|
complete([])
|
||||||
return
|
return
|
||||||
@ -155,6 +155,8 @@ func processWindowsForTabs(wins: [SFSafariWindow], options: TabQueryOptions?, co
|
|||||||
newTabs.append(t)
|
newTabs.append(t)
|
||||||
tabGroup.leave()
|
tabGroup.leave()
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
tabGroup.leave()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
makeTabObject(tab: tab, activeTab: activeTab, windowIndex: windowIndex, tabIndex: tabIndex, complete: { (t) in
|
makeTabObject(tab: tab, activeTab: activeTab, windowIndex: windowIndex, tabIndex: tabIndex, complete: { (t) in
|
||||||
@ -164,14 +166,16 @@ func processWindowsForTabs(wins: [SFSafariWindow], options: TabQueryOptions?, co
|
|||||||
}
|
}
|
||||||
tabIndex = tabIndex + 1
|
tabIndex = tabIndex + 1
|
||||||
}
|
}
|
||||||
tabGroup.wait()
|
tabGroup.notify(queue: .main){
|
||||||
winGroup.leave()
|
winGroup.leave()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
windowIndex = windowIndex + 1
|
windowIndex = windowIndex + 1
|
||||||
}
|
}
|
||||||
winGroup.wait()
|
winGroup.notify(queue: .main){
|
||||||
complete(newTabs)
|
complete(newTabs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeTabObject(tab: SFSafariTab, activeTab: SFSafariTab?, windowIndex: Int, tabIndex: Int, complete: @escaping (Tab) -> Void) {
|
func makeTabObject(tab: SFSafariTab, activeTab: SFSafariTab?, windowIndex: Int, tabIndex: Int, complete: @escaping (Tab) -> Void) {
|
||||||
|
Loading…
Reference in New Issue
Block a user