Fix unused locals and better receiver selector available media checking

This commit is contained in:
hensm
2019-08-16 12:57:23 +01:00
parent 1c67354e1d
commit e2eca07876
28 changed files with 282 additions and 363 deletions

View File

@@ -1,8 +1,5 @@
"use strict";
import { Message } from "../types";
const WEBSOCKET_DAEMON_URL = "ws://localhost:9556";

View File

@@ -3,7 +3,6 @@
import defaultOptions from "../defaultOptions";
import { ReceiverSelectorType } from "../background/receiverSelector";
import { Message } from "../types";
import { TypedEventTarget } from "./typedEvents";

View File

@@ -1,5 +1,8 @@
"use strict";
import { ReceiverSelectorMediaType } from "../background/receiverSelector";
export function getNextEllipsis (ellipsis: string): string {
/* tslint:disable:curly */
if (ellipsis === "") return ".";
@@ -29,6 +32,28 @@ export function stringify (
return formattedString;
}
export function getMediaTypesForPageUrl (
pageUrl: string): ReceiverSelectorMediaType {
let availableMediaTypes =
ReceiverSelectorMediaType.App
| ReceiverSelectorMediaType.Tab
| ReceiverSelectorMediaType.Screen
| ReceiverSelectorMediaType.File;
/**
* Remove "Screen" option when on an insecure origin as
* MediaDevices.getDisplayMedia will not exist (and legacy
* MediaDevices.getUserMedia mediaSource constraint will
* fail).
*/
if (!pageUrl.startsWith("https://")) {
availableMediaTypes &= ~ReceiverSelectorMediaType.Screen;
}
return availableMediaTypes;
}
interface WindowCenteredProps {
width: number;