mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-18 11:05:41 +01:00
reload popup on open of safari app popover
This commit is contained in:
parent
42c44c381a
commit
6fe414ffbd
@ -42,10 +42,10 @@ export class SafariApp {
|
||||
if (message == null) {
|
||||
return;
|
||||
}
|
||||
if ((message.id == null || message.id === '') && message.command === 'cs_message') {
|
||||
if ((message.id == null || message.id === '') && message.command === 'app_message') {
|
||||
try {
|
||||
const msg = JSON.parse(message.data);
|
||||
SafariApp.sendMessageToListeners(msg, 'cs_message', null);
|
||||
SafariApp.sendMessageToListeners(msg, 'app_message', null);
|
||||
} catch { }
|
||||
} else if (message.id != null && (window as any).bitwardenSafariAppRequests.has(message.id)) {
|
||||
const p = (window as any).bitwardenSafariAppRequests.get(message.id);
|
||||
|
@ -127,6 +127,8 @@ export class AppComponent implements OnInit {
|
||||
// Wait to make sure background has reloaded first.
|
||||
window.setTimeout(() => BrowserApi.reloadExtension(window), 2000);
|
||||
}
|
||||
} else if (msg.command === 'reloadPopup') {
|
||||
this.router.navigate(['/']);
|
||||
} else {
|
||||
msg.webExtSender = sender;
|
||||
this.broadcasterService.send(msg);
|
||||
|
@ -16,7 +16,7 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||
page.getPropertiesWithCompletionHandler { properties in
|
||||
// NSLog("The extension received a message (\(messageName)) from a script injected into (\(String(describing: properties?.url))) with userInfo (\(userInfo ?? [:]))")
|
||||
DispatchQueue.main.async {
|
||||
SafariExtensionViewController.shared.replyMessageFromScript(msg: userInfo)
|
||||
SafariExtensionViewController.shared.sendMessage(msg: userInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -35,5 +35,11 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||
override func popoverViewController() -> SFSafariExtensionViewController {
|
||||
return SafariExtensionViewController.shared
|
||||
}
|
||||
|
||||
override func popoverWillShow(in window: SFSafariWindow) {
|
||||
DispatchQueue.main.async {
|
||||
SafariExtensionViewController.shared.sendMessage(msg: ["command": "reloadPopup"])
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -153,12 +153,12 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
|
||||
webView.evaluateJavaScript("window.bitwardenSafariAppMessageReceiver(\(json));", completionHandler: nil)
|
||||
}
|
||||
|
||||
func replyMessageFromScript(msg: [String : Any]?) {
|
||||
func sendMessage(msg: [String : Any]?) {
|
||||
if(webView == nil) {
|
||||
return;
|
||||
}
|
||||
let newMsg = AppMessage()
|
||||
newMsg.command = "cs_message"
|
||||
newMsg.command = "app_message"
|
||||
do {
|
||||
let jsonData = try JSONSerialization.data(withJSONObject: msg as Any, options: [])
|
||||
newMsg.data = String(data: jsonData, encoding: .utf8)
|
||||
|
Loading…
Reference in New Issue
Block a user