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

@@ -16,7 +16,6 @@ export default class PopupReceiverSelector
implements ReceiverSelector {
private windowId: number;
private openerWindowId: number;
private messagePort: browser.runtime.Port;
private messagePortDisconnected: boolean;
@@ -102,7 +101,6 @@ export default class PopupReceiverSelector
this._isOpen = true;
this.windowId = popup.id;
this.openerWindowId = openerWindow.id;
// Size/position not set correctly on creation (bug?)
await browser.windows.update(this.windowId, {
@@ -168,7 +166,6 @@ export default class PopupReceiverSelector
// Cleanup
this.windowId = null;
this.openerWindowId = null;
this.messagePort = null;
this.receivers = null;
this.defaultMediaType = null;

View File

@@ -83,6 +83,29 @@ async function getSelection (
});
const opts = await options.getAll();
// Remove mirroring media types if mirroring is not enabled.
if (!opts.mirroringEnabled) {
availableMediaTypes &= ~(
ReceiverSelectorMediaType.Tab
| ReceiverSelectorMediaType.Screen);
}
// Remove file media type if local media is not enabled
if (!opts.mediaEnabled || !opts.localMediaEnabled) {
availableMediaTypes &= ~ReceiverSelectorMediaType.File;
}
if (!availableMediaTypes || availableMediaTypes
=== ReceiverSelectorMediaType.File) {
console.error("fx_cast (Debug): No available media types");
resolve(null);
return;
}
// Ensure status manager is initialized
await StatusManager.init();