diff --git a/src/browser/browserApi.ts b/src/browser/browserApi.ts index 73c589e008..9f15fe201c 100644 --- a/src/browser/browserApi.ts +++ b/src/browser/browserApi.ts @@ -1,3 +1,5 @@ +import { SafariApp } from './safariApp'; + export class BrowserApi { static isWebExtensionsApi: boolean = (typeof browser !== 'undefined'); static isSafariApi: boolean = (window as any).safariAppExtension === true; @@ -222,7 +224,7 @@ export class BrowserApi { } else if (BrowserApi.isWebExtensionsApi || BrowserApi.isChromeApi) { win.close(); } else if (BrowserApi.isSafariApi && safari.extension.popovers && safari.extension.popovers.length > 0) { - BrowserApi.sendSafariMessageToApp({ command: 'hideWindow' }); + SafariApp.sendMessageToApp('hideWindow'); } } @@ -286,7 +288,7 @@ export class BrowserApi { if (win != null) { return win.location.reload(true); } else if (BrowserApi.isSafariApi) { - BrowserApi.sendSafariMessageToApp({ command: 'reloadWindow' }); + SafariApp.sendMessageToApp('reloadWindow'); } else if (!BrowserApi.isSafariApi) { return chrome.runtime.reload(); } diff --git a/src/services/browserMessaging.service.ts b/src/services/browserMessaging.service.ts index aeaa14db19..2ea3b0cdfc 100644 --- a/src/services/browserMessaging.service.ts +++ b/src/services/browserMessaging.service.ts @@ -1,14 +1,14 @@ import { BrowserApi } from '../browser/browserApi'; +import { SafariApp } from '../browser/safariApp'; -import { MessagingService } from 'jslib/abstractions'; +import { MessagingService } from 'jslib/abstractions/messaging.service'; export default class BrowserMessagingService implements MessagingService { send(subscriber: string, arg: any = {}) { - const message = Object.assign({}, { command: subscriber }, arg); - if (BrowserApi.isSafariApi) { - BrowserApi.sendSafariMessageToApp(message); + SafariApp.sendMessageToApp(subscriber, arg); } else { + const message = Object.assign({}, { command: subscriber }, arg); chrome.runtime.sendMessage(message); } }