mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-12 02:29:59 +00:00
Cleanup popup messages
This commit is contained in:
@@ -25,7 +25,8 @@ export default class PopupReceiverSelector extends ReceiverSelector {
|
|||||||
private availableMediaTypes?: ReceiverSelectorMediaType;
|
private availableMediaTypes?: ReceiverSelectorMediaType;
|
||||||
|
|
||||||
private wasReceiverSelected: boolean = false;
|
private wasReceiverSelected: boolean = false;
|
||||||
private requestedAppId?: string;
|
|
||||||
|
private appId?: string;
|
||||||
|
|
||||||
#isOpen = false;
|
#isOpen = false;
|
||||||
|
|
||||||
@@ -55,9 +56,9 @@ export default class PopupReceiverSelector extends ReceiverSelector {
|
|||||||
receivers: Receiver[]
|
receivers: Receiver[]
|
||||||
, defaultMediaType: ReceiverSelectorMediaType
|
, defaultMediaType: ReceiverSelectorMediaType
|
||||||
, availableMediaTypes: ReceiverSelectorMediaType
|
, availableMediaTypes: ReceiverSelectorMediaType
|
||||||
, requestedAppId?: string): Promise<void> {
|
, appId?: string): Promise<void> {
|
||||||
|
|
||||||
this.requestedAppId = requestedAppId;
|
this.appId = appId;
|
||||||
|
|
||||||
// If popup already exists, close it
|
// If popup already exists, close it
|
||||||
if (this.windowId) {
|
if (this.windowId) {
|
||||||
@@ -117,7 +118,7 @@ export default class PopupReceiverSelector extends ReceiverSelector {
|
|||||||
public update (receivers: Receiver[]) {
|
public update (receivers: Receiver[]) {
|
||||||
this.receivers = receivers;
|
this.receivers = receivers;
|
||||||
this.messagePort?.postMessage({
|
this.messagePort?.postMessage({
|
||||||
subject: "popup:/populateReceiverList"
|
subject: "popup:/update"
|
||||||
, data: {
|
, data: {
|
||||||
receivers: this.receivers
|
receivers: this.receivers
|
||||||
}
|
}
|
||||||
@@ -130,7 +131,7 @@ export default class PopupReceiverSelector extends ReceiverSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.#isOpen = false;
|
this.#isOpen = false;
|
||||||
this.requestedAppId = undefined;
|
this.appId = undefined;
|
||||||
|
|
||||||
if (this.messagePort && !this.messagePortDisconnected) {
|
if (this.messagePort && !this.messagePortDisconnected) {
|
||||||
this.messagePort.disconnect();
|
this.messagePort.disconnect();
|
||||||
@@ -161,12 +162,12 @@ export default class PopupReceiverSelector extends ReceiverSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.messagePort.postMessage({
|
this.messagePort.postMessage({
|
||||||
subject: "popup:/sendRequestedAppId"
|
subject: "popup:/init"
|
||||||
, data: { requestedAppId: this.requestedAppId }
|
, data: { appId: this.appId }
|
||||||
});
|
});
|
||||||
|
|
||||||
this.messagePort.postMessage({
|
this.messagePort.postMessage({
|
||||||
subject: "popup:/populateReceiverList"
|
subject: "popup:/update"
|
||||||
, data: {
|
, data: {
|
||||||
receivers: this.receivers
|
receivers: this.receivers
|
||||||
, defaultMediaType: this.defaultMediaType
|
, defaultMediaType: this.defaultMediaType
|
||||||
|
|||||||
@@ -14,10 +14,8 @@ import { MediaInfo } from "./shim/cast/media";
|
|||||||
|
|
||||||
|
|
||||||
type MessagesBase = {
|
type MessagesBase = {
|
||||||
"popup:/sendRequestedAppId": {
|
"popup:/init": { appId?: string }
|
||||||
requestedAppId?: string
|
, "popup:/update": {
|
||||||
}
|
|
||||||
, "popup:/populateReceiverList": {
|
|
||||||
receivers: Receiver[]
|
receivers: Receiver[]
|
||||||
, defaultMediaType?: ReceiverSelectorMediaType
|
, defaultMediaType?: ReceiverSelectorMediaType
|
||||||
, availableMediaTypes?: ReceiverSelectorMediaType
|
, availableMediaTypes?: ReceiverSelectorMediaType
|
||||||
|
|||||||
@@ -73,15 +73,15 @@ class PopupApp extends Component<{}, PopupAppState> {
|
|||||||
|
|
||||||
this.port.onMessage.addListener((message: Message) => {
|
this.port.onMessage.addListener((message: Message) => {
|
||||||
switch (message.subject) {
|
switch (message.subject) {
|
||||||
case "popup:/sendRequestedAppId": {
|
case "popup:/init": {
|
||||||
this.setState({
|
this.setState({
|
||||||
requestedAppId: message.data?.requestedAppId
|
requestedAppId: message.data?.appId
|
||||||
});
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "popup:/populateReceiverList": {
|
case "popup:/update": {
|
||||||
const { receivers
|
const { receivers
|
||||||
, availableMediaTypes
|
, availableMediaTypes
|
||||||
, defaultMediaType } = message.data;
|
, defaultMediaType } = message.data;
|
||||||
|
|||||||
Reference in New Issue
Block a user