mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-08 08:39:59 +00:00
Remove disabled action state entirely
This commit is contained in:
@@ -9,13 +9,9 @@
|
||||
},
|
||||
|
||||
"actionTitleDefault": {
|
||||
"message": "fx_cast: Ready to cast",
|
||||
"message": "fx_cast",
|
||||
"description": "Title for toolbar button in default state."
|
||||
},
|
||||
"actionTitleDisabled": {
|
||||
"message": "fx_cast: Unable to cast",
|
||||
"description": "Title for toolbar button in disabled state."
|
||||
},
|
||||
"actionTitleConnecting": {
|
||||
"message": "fx_cast: Connecting",
|
||||
"description": "Title for toolbar button whilst connecting."
|
||||
|
||||
@@ -14,8 +14,7 @@ const isDarkTheme = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
export enum ActionState {
|
||||
Default,
|
||||
Connecting,
|
||||
Connected,
|
||||
Disabled
|
||||
Connected
|
||||
}
|
||||
|
||||
/** Updates action details depending on given state. */
|
||||
@@ -29,9 +28,6 @@ export function updateActionState(state: ActionState, tabId?: number) {
|
||||
case ActionState.Default:
|
||||
title = _("actionTitleDefault");
|
||||
break;
|
||||
case ActionState.Disabled:
|
||||
title = _("actionTitleDisabled");
|
||||
break;
|
||||
case ActionState.Connecting:
|
||||
title = _("actionTitleConnecting");
|
||||
path = isDarkTheme
|
||||
@@ -44,12 +40,6 @@ export function updateActionState(state: ActionState, tabId?: number) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (state === ActionState.Disabled) {
|
||||
browser.browserAction.disable(tabId);
|
||||
} else {
|
||||
browser.browserAction.enable(tabId);
|
||||
}
|
||||
|
||||
browser.browserAction.setTitle({ tabId, title });
|
||||
browser.browserAction.setIcon({ tabId, path });
|
||||
}
|
||||
@@ -57,6 +47,8 @@ export function updateActionState(state: ActionState, tabId?: number) {
|
||||
export function initAction() {
|
||||
logger.info("init (action)");
|
||||
|
||||
updateActionState(ActionState.Default);
|
||||
|
||||
browser.browserAction.onClicked.addListener(async tab => {
|
||||
if (tab.id === undefined) {
|
||||
logger.error("Tab ID not found in browser action handler.");
|
||||
|
||||
@@ -47,7 +47,7 @@ export default new (class extends TypedEventTarget<EventMap> {
|
||||
async refresh() {
|
||||
this.bridgePort?.disconnect();
|
||||
|
||||
updateActionState(ActionState.Disabled);
|
||||
updateActionState(ActionState.Default);
|
||||
|
||||
try {
|
||||
this.bridgeInfo = await bridge.getInfo();
|
||||
@@ -69,14 +69,6 @@ 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;
|
||||
}
|
||||
@@ -154,8 +146,6 @@ export default new (class extends TypedEventTarget<EventMap> {
|
||||
})
|
||||
);
|
||||
|
||||
this.updateAction();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -171,8 +161,6 @@ export default new (class extends TypedEventTarget<EventMap> {
|
||||
})
|
||||
);
|
||||
|
||||
this.updateAction();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user