isPopoverOpen for safari app
This commit is contained in:
parent
deb5d2bf62
commit
7d2c4cbd9a
|
@ -168,14 +168,14 @@ export class BrowserApi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static isPopupOpen(): boolean {
|
static async isPopupOpen(): Promise<boolean> {
|
||||||
if (BrowserApi.isChromeApi) {
|
if (BrowserApi.isChromeApi) {
|
||||||
return chrome.extension.getViews({ type: 'popup' }).length > 0;
|
return Promise.resolve(chrome.extension.getViews({ type: 'popup' }).length > 0);
|
||||||
} else if (BrowserApi.isSafariApi) {
|
} else if (BrowserApi.isSafariApi) {
|
||||||
// TODO
|
const open = await SafariApp.sendMessageToApp('isPopoverOpen');
|
||||||
return true;
|
return open === 'true';
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return Promise.resolve(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,9 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
|
||||||
self.replyMessage(message: m!)
|
self.replyMessage(message: m!)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
} else if command == "isPopoverOpen" {
|
||||||
|
m!.responseData = "true";
|
||||||
|
replyMessage(message: m!)
|
||||||
} else if command == "reloadExtension" {
|
} else if command == "reloadExtension" {
|
||||||
webView?.reload()
|
webView?.reload()
|
||||||
replyMessage(message: m!)
|
replyMessage(message: m!)
|
||||||
|
|
|
@ -89,23 +89,23 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
|
||||||
return this.analyticsIdCache;
|
return this.analyticsIdCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
isViewOpen(): Promise<boolean> {
|
async isViewOpen(): Promise<boolean> {
|
||||||
if (BrowserApi.isPopupOpen()) {
|
if (await BrowserApi.isPopupOpen()) {
|
||||||
return Promise.resolve(true);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isSafari()) {
|
if (this.isSafari()) {
|
||||||
return Promise.resolve(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sidebarView = this.sidebarViewName();
|
const sidebarView = this.sidebarViewName();
|
||||||
const sidebarOpen = sidebarView != null && chrome.extension.getViews({ type: sidebarView }).length > 0;
|
const sidebarOpen = sidebarView != null && chrome.extension.getViews({ type: sidebarView }).length > 0;
|
||||||
if (sidebarOpen) {
|
if (sidebarOpen) {
|
||||||
return Promise.resolve(true);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tabOpen = chrome.extension.getViews({ type: 'tab' }).length > 0;
|
const tabOpen = chrome.extension.getViews({ type: 'tab' }).length > 0;
|
||||||
return Promise.resolve(tabOpen);
|
return tabOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
lockTimeout(): number {
|
lockTimeout(): number {
|
||||||
|
|
Loading…
Reference in New Issue