mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-10 01:29:58 +00:00
Document extension messages and remove unnecessary messages/message data
This commit is contained in:
@@ -67,7 +67,8 @@ export default class ReceiverSelector extends TypedEventTarget<ReceiverSelectorE
|
||||
private wasReceiverSelected = false;
|
||||
|
||||
private appId?: string;
|
||||
private pageInfo?: ReceiverSelectorPageInfo;
|
||||
|
||||
pageInfo?: ReceiverSelectorPageInfo;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
@@ -93,7 +93,7 @@ export default new (class {
|
||||
|
||||
instance.contentPort.postMessage({
|
||||
subject: "cast:initialized",
|
||||
data: await bridge.getInfo()
|
||||
data: { isAvailable: (await bridge.getInfo()).isVersionCompatible }
|
||||
});
|
||||
|
||||
return instance;
|
||||
@@ -197,12 +197,26 @@ export default new (class {
|
||||
) {
|
||||
// Intercept messages to store relevant info
|
||||
switch (message.subject) {
|
||||
case "cast:sessionCreated":
|
||||
case "cast:sessionCreated": {
|
||||
// Close after session is created
|
||||
const selector = ReceiverSelector.sharedInstance;
|
||||
if (
|
||||
selector.isOpen &&
|
||||
// If selector context is the same as the instance context
|
||||
selector.pageInfo?.tabId === instance.contentTabId &&
|
||||
selector.pageInfo?.frameId === instance.contentFrameId &&
|
||||
// If selector is supposed to close
|
||||
(await options.get("receiverSelectorWaitForConnection"))
|
||||
) {
|
||||
selector.close();
|
||||
}
|
||||
|
||||
instance.session = {
|
||||
deviceId: message.data.receiverId,
|
||||
sessionId: message.data.sessionId
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
instance.contentPort.postMessage(message);
|
||||
@@ -296,23 +310,6 @@ export default new (class {
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: If we're closing a selector, make sure it's the
|
||||
* same one that caused the session creation.
|
||||
*/
|
||||
case "main:closeReceiverSelector": {
|
||||
const selector = ReceiverSelector.sharedInstance;
|
||||
const shouldClose = await options.get(
|
||||
"receiverSelectorWaitForConnection"
|
||||
);
|
||||
|
||||
if (selector.isOpen && shouldClose) {
|
||||
selector.close();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user