1
0
mirror of https://github.com/bitwarden/browser synced 2024-12-26 18:04:07 +01:00

Merge pull request #1238 from bitwarden/swift-nil-unwrap-exception

Potential fix for swift nil unwrap exception
This commit is contained in:
Chad Scharf 2020-05-20 10:45:45 -04:00 committed by GitHub
commit 47c9047fa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,10 +101,19 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
let options: TabQueryOptions? = jsonDeserialize(json: m!.data)
if options?.currentWindow ?? false {
SFSafariApplication.getActiveWindow { win in
processWindowsForTabs(wins: [win!], options: options, complete: { tabs in
m!.responseData = jsonSerialize(obj: tabs)
self.replyMessage(message: m!)
})
if win != nil {
processWindowsForTabs(wins: [win!], options: options, complete: { tabs in
m!.responseData = jsonSerialize(obj: tabs)
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 {
SFSafariApplication.getAllWindows { wins in
@ -145,10 +154,12 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
dismissPopover()
replyMessage(message: m!)
} else if command == "showPopover" {
SFSafariApplication.getActiveWindow { win in
win?.getToolbarItem(completionHandler: { item in
item?.showPopover()
})
if popoverOpenCount <= 0 {
SFSafariApplication.getActiveWindow { win in
win?.getToolbarItem(completionHandler: { item in
item?.showPopover()
})
}
}
} else if command == "isPopoverOpen" {
m!.responseData = popoverOpenCount > 0 ? "true" : "false"