Stop erroneously sending availability updates to receiver action listeners

This commit is contained in:
hensm
2018-12-13 19:54:22 +00:00
parent e42766097f
commit 414669df51

View File

@@ -166,7 +166,7 @@ onMessage(message => {
* Cast destination found (serviceUp). Set the API availability * Cast destination found (serviceUp). Set the API availability
* property and call the page event function (__onGCastApiAvailable). * property and call the page event function (__onGCastApiAvailable).
*/ */
case "shim:serviceUp": case "shim:serviceUp": {
const receiver = new Receiver( const receiver = new Receiver(
message.data.id message.data.id
, message.data.friendlyName); , message.data.friendlyName);
@@ -182,16 +182,15 @@ onMessage(message => {
// Notify listeners of new cast destination // Notify listeners of new cast destination
state.apiConfig.receiverListener(ReceiverAvailability.AVAILABLE); state.apiConfig.receiverListener(ReceiverAvailability.AVAILABLE);
receiverListeners.forEach(
listener => listener(ReceiverAvailability.AVAILABLE));
break; break;
};
/** /**
* Cast destination lost (serviceDown). Remove from the receiver list * Cast destination lost (serviceDown). Remove from the receiver list
* and update availability state. * and update availability state.
*/ */
case "shim:serviceDown": case "shim:serviceDown": {
state.receiverList = state.receiverList.filter( state.receiverList = state.receiverList.filter(
receiver => receiver.label !== message.data.id); receiver => receiver.label !== message.data.id);
@@ -201,8 +200,9 @@ onMessage(message => {
} }
break; break;
};
case "shim:selectReceiver": case "shim:selectReceiver": {
console.info("Caster (Debug): Selected receiver"); console.info("Caster (Debug): Selected receiver");
const selectedReceiver = message.data.receiver; const selectedReceiver = message.data.receiver;
@@ -239,12 +239,13 @@ onMessage(message => {
state.sessionList.push(new Session(...sessionConstructorArgs)); state.sessionList.push(new Session(...sessionConstructorArgs));
break; break;
};
/** /**
* Popup is ready to receive data to populate the cast destination * Popup is ready to receive data to populate the cast destination
* chooser. * chooser.
*/ */
case "shim:popupReady": case "shim:popupReady": {
sendMessage({ sendMessage({
subject: "popup:populate" subject: "popup:populate"
, data: { , data: {
@@ -252,7 +253,9 @@ onMessage(message => {
, selectedMedia: state.apiConfig._selectedMedia , selectedMedia: state.apiConfig._selectedMedia
} }
}); });
break; break;
};
} }
}); });