Add options checks for waitForConnection and closeIfFocusLost

This commit is contained in:
hensm
2019-07-26 03:39:13 +01:00
parent c53a21008c
commit a046ba9022
6 changed files with 42 additions and 10 deletions

View File

@@ -4,6 +4,8 @@ import ReceiverSelector, {
ReceiverSelectorEvents
, ReceiverSelectorMediaType } from "./ReceiverSelector";
import options from "../lib/options";
import { TypedEventTarget } from "../lib/typedEvents";
import { getWindowCenteredProps } from "../lib/utils";
import { Message, Receiver } from "../types";
@@ -107,9 +109,15 @@ export default class PopupReceiverSelector
...centeredProps
});
// Add focus listener
browser.windows.onFocusChanged.addListener(
this.onWindowsFocusChanged);
const closeIfFocusLost = await options.get(
"receiverSelectorCloseIfFocusLost");
if (closeIfFocusLost) {
// Add focus listener
browser.windows.onFocusChanged.addListener(
this.onWindowsFocusChanged);
}
}
public async close (): Promise<void> {