mirror of
https://github.com/bitwarden/browser
synced 2024-12-27 10:23:48 +01:00
Merge pull request #1238 from bitwarden/swift-nil-unwrap-exception
Potential fix for swift nil unwrap exception
This commit is contained in:
commit
47c9047fa8
@ -101,10 +101,19 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
|
|||||||
let options: TabQueryOptions? = jsonDeserialize(json: m!.data)
|
let options: TabQueryOptions? = jsonDeserialize(json: m!.data)
|
||||||
if options?.currentWindow ?? false {
|
if options?.currentWindow ?? false {
|
||||||
SFSafariApplication.getActiveWindow { win in
|
SFSafariApplication.getActiveWindow { win in
|
||||||
|
if win != nil {
|
||||||
processWindowsForTabs(wins: [win!], options: options, complete: { tabs in
|
processWindowsForTabs(wins: [win!], options: options, complete: { tabs in
|
||||||
m!.responseData = jsonSerialize(obj: tabs)
|
m!.responseData = jsonSerialize(obj: tabs)
|
||||||
self.replyMessage(message: m!)
|
self.replyMessage(message: m!)
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
SFSafariApplication.getAllWindows { wins in
|
||||||
|
processWindowsForTabs(wins: wins, options: options, complete: { tabs in
|
||||||
|
m!.responseData = jsonSerialize(obj: tabs)
|
||||||
|
self.replyMessage(message: m!)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SFSafariApplication.getAllWindows { wins in
|
SFSafariApplication.getAllWindows { wins in
|
||||||
@ -145,11 +154,13 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
|
|||||||
dismissPopover()
|
dismissPopover()
|
||||||
replyMessage(message: m!)
|
replyMessage(message: m!)
|
||||||
} else if command == "showPopover" {
|
} else if command == "showPopover" {
|
||||||
|
if popoverOpenCount <= 0 {
|
||||||
SFSafariApplication.getActiveWindow { win in
|
SFSafariApplication.getActiveWindow { win in
|
||||||
win?.getToolbarItem(completionHandler: { item in
|
win?.getToolbarItem(completionHandler: { item in
|
||||||
item?.showPopover()
|
item?.showPopover()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if command == "isPopoverOpen" {
|
} else if command == "isPopoverOpen" {
|
||||||
m!.responseData = popoverOpenCount > 0 ? "true" : "false"
|
m!.responseData = popoverOpenCount > 0 ? "true" : "false"
|
||||||
replyMessage(message: m!)
|
replyMessage(message: m!)
|
||||||
|
Loading…
Reference in New Issue
Block a user