diff --git a/ext/src/_locales/en/messages.json b/ext/src/_locales/en/messages.json index 82e2c2a..98d2293 100755 --- a/ext/src/_locales/en/messages.json +++ b/ext/src/_locales/en/messages.json @@ -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." diff --git a/ext/src/background/action.ts b/ext/src/background/action.ts index ac8ecb4..3afc8b7 100644 --- a/ext/src/background/action.ts +++ b/ext/src/background/action.ts @@ -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."); diff --git a/ext/src/background/deviceManager.ts b/ext/src/background/deviceManager.ts index 085c435..3529a33 100644 --- a/ext/src/background/deviceManager.ts +++ b/ext/src/background/deviceManager.ts @@ -47,7 +47,7 @@ export default new (class extends TypedEventTarget { 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 { } } - 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 { }) ); - this.updateAction(); - break; } @@ -171,8 +161,6 @@ export default new (class extends TypedEventTarget { }) ); - this.updateAction(); - break; }