mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-10 01:29:58 +00:00
Add popup warning banner when the bridge has a problem
This commit is contained in:
@@ -59,7 +59,7 @@ export default class ReceiverSelector extends TypedEventTarget<ReceiverSelectorE
|
||||
appInfo?: ReceiverSelectorAppInfo;
|
||||
pageInfo?: ReceiverSelectorPageInfo;
|
||||
|
||||
constructor() {
|
||||
constructor(private isBridgeCompatible: boolean) {
|
||||
super();
|
||||
|
||||
this.onConnect = this.onConnect.bind(this);
|
||||
@@ -205,7 +205,8 @@ export default class ReceiverSelector extends TypedEventTarget<ReceiverSelectorE
|
||||
subject: "popup:init",
|
||||
data: {
|
||||
appInfo: this.appInfo,
|
||||
pageInfo: this.pageInfo
|
||||
pageInfo: this.pageInfo,
|
||||
isBridgeCompatible: this.isBridgeCompatible
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -710,7 +710,9 @@ async function getReceiverSelection(selectionOpts: {
|
||||
*/
|
||||
function createSelector() {
|
||||
// Get a new selector for each selection
|
||||
const selector = new ReceiverSelector();
|
||||
const selector = new ReceiverSelector(
|
||||
deviceManager.getBridgeInfo()?.isVersionCompatible ?? false
|
||||
);
|
||||
|
||||
/**
|
||||
* Sends message to cast instance to trigger stopped receiver action
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import bridge from "../lib/bridge";
|
||||
import bridge, { BridgeInfo } from "../lib/bridge";
|
||||
import logger from "../lib/logger";
|
||||
import { TypedEventTarget } from "../lib/TypedEventTarget";
|
||||
|
||||
@@ -34,6 +34,7 @@ export default new (class extends TypedEventTarget<EventMap> {
|
||||
private receiverDevices = new Map<string, ReceiverDevice>();
|
||||
|
||||
private bridgePort?: Port;
|
||||
private bridgeInfo?: BridgeInfo;
|
||||
async init() {
|
||||
if (!this.bridgePort) {
|
||||
await this.refresh();
|
||||
@@ -48,17 +49,28 @@ export default new (class extends TypedEventTarget<EventMap> {
|
||||
this.bridgePort?.disconnect();
|
||||
this.receiverDevices.clear();
|
||||
|
||||
this.bridgePort = await bridge.connect();
|
||||
this.bridgePort.onMessage.addListener(this.onBridgeMessage);
|
||||
this.bridgePort.onDisconnect.addListener(this.onBridgeDisconnect);
|
||||
try {
|
||||
this.bridgeInfo = await bridge.getInfo();
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch {}
|
||||
|
||||
this.bridgePort.postMessage({
|
||||
subject: "bridge:startDiscovery",
|
||||
data: {
|
||||
// Also send back status messages
|
||||
shouldWatchStatus: true
|
||||
}
|
||||
});
|
||||
if (this.bridgeInfo?.isVersionCompatible) {
|
||||
this.bridgePort = await bridge.connect();
|
||||
this.bridgePort.onMessage.addListener(this.onBridgeMessage);
|
||||
this.bridgePort.onDisconnect.addListener(this.onBridgeDisconnect);
|
||||
|
||||
this.bridgePort.postMessage({
|
||||
subject: "bridge:startDiscovery",
|
||||
data: {
|
||||
// Also send back status messages
|
||||
shouldWatchStatus: true
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getBridgeInfo() {
|
||||
return this.bridgeInfo;
|
||||
}
|
||||
|
||||
/** Gets a list of receiver devices. */
|
||||
|
||||
Reference in New Issue
Block a user