mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-10 09:39:58 +00:00
Set browser action details to match cast session states
This commit is contained in:
@@ -13,6 +13,8 @@ import type {
|
||||
} from "../cast/sdk/types";
|
||||
import { PlayerState } from "../cast/sdk/media/enums";
|
||||
|
||||
import { ActionState, updateActionState } from "./action";
|
||||
|
||||
interface EventMap {
|
||||
deviceUp: { deviceInfo: ReceiverDevice };
|
||||
deviceDown: { deviceId: string };
|
||||
@@ -45,6 +47,8 @@ export default new (class extends TypedEventTarget<EventMap> {
|
||||
async refresh() {
|
||||
this.bridgePort?.disconnect();
|
||||
|
||||
updateActionState(ActionState.Disabled);
|
||||
|
||||
try {
|
||||
this.bridgeInfo = await bridge.getInfo();
|
||||
// eslint-disable-next-line no-empty
|
||||
@@ -65,6 +69,14 @@ export default new (class extends TypedEventTarget<EventMap> {
|
||||
}
|
||||
}
|
||||
|
||||
private updateAction() {
|
||||
if (this.receiverDevices.size > 0) {
|
||||
updateActionState(ActionState.Default);
|
||||
} else {
|
||||
updateActionState(ActionState.Disabled);
|
||||
}
|
||||
}
|
||||
|
||||
getBridgeInfo() {
|
||||
return this.bridgeInfo;
|
||||
}
|
||||
@@ -142,6 +154,8 @@ export default new (class extends TypedEventTarget<EventMap> {
|
||||
})
|
||||
);
|
||||
|
||||
this.updateAction();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -157,6 +171,8 @@ export default new (class extends TypedEventTarget<EventMap> {
|
||||
})
|
||||
);
|
||||
|
||||
this.updateAction();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user