Remove disabled action icons and use deviceManager default action state

This commit is contained in:
hensm
2022-09-10 20:21:10 +01:00
parent e761d4756a
commit 3a38190478
3 changed files with 7 additions and 24 deletions

View File

@@ -8,8 +8,6 @@ const ACTION_ICON_DEFAULT_LIGHT = "icons/cast-default-light.svg";
const ACTION_ICON_CONNECTING_DARK = "icons/cast-connecting-dark.svg"; const ACTION_ICON_CONNECTING_DARK = "icons/cast-connecting-dark.svg";
const ACTION_ICON_CONNECTING_LIGHT = "icons/cast-connecting-light.svg"; const ACTION_ICON_CONNECTING_LIGHT = "icons/cast-connecting-light.svg";
const ACTION_ICON_CONNECTED = "icons/cast-connected.svg"; const ACTION_ICON_CONNECTED = "icons/cast-connected.svg";
const ACTION_ICON_DISABLED_DARK = "icons/cast-disabled-dark.svg";
const ACTION_ICON_DISABLED_LIGHT = "icons/cast-disabled-light.svg";
const isDarkTheme = window.matchMedia("(prefers-color-scheme: dark)").matches; const isDarkTheme = window.matchMedia("(prefers-color-scheme: dark)").matches;
@@ -23,13 +21,16 @@ export enum ActionState {
/** Updates action details depending on given state. */ /** Updates action details depending on given state. */
export function updateActionState(state: ActionState, tabId?: number) { export function updateActionState(state: ActionState, tabId?: number) {
let title: string; let title: string;
let path: string; let path = isDarkTheme
? ACTION_ICON_DEFAULT_LIGHT
: ACTION_ICON_DEFAULT_DARK;
switch (state) { switch (state) {
case ActionState.Default: case ActionState.Default:
title = _("actionTitleDefault"); title = _("actionTitleDefault");
path = isDarkTheme break;
? ACTION_ICON_DEFAULT_LIGHT case ActionState.Disabled:
: ACTION_ICON_DEFAULT_DARK; title = _("actionTitleDisabled");
break; break;
case ActionState.Connecting: case ActionState.Connecting:
title = _("actionTitleConnecting"); title = _("actionTitleConnecting");
@@ -41,12 +42,6 @@ export function updateActionState(state: ActionState, tabId?: number) {
title = _("actionTitleConnected"); title = _("actionTitleConnected");
path = ACTION_ICON_CONNECTED; path = ACTION_ICON_CONNECTED;
break; break;
case ActionState.Disabled:
title = _("actionTitleDisabled");
path = isDarkTheme
? ACTION_ICON_DISABLED_LIGHT
: ACTION_ICON_DISABLED_DARK;
break;
} }
if (state === ActionState.Disabled) { if (state === ActionState.Disabled) {
@@ -62,8 +57,6 @@ export function updateActionState(state: ActionState, tabId?: number) {
export function initAction() { export function initAction() {
logger.info("init (action)"); logger.info("init (action)");
updateActionState(ActionState.Default);
browser.browserAction.onClicked.addListener(async tab => { browser.browserAction.onClicked.addListener(async tab => {
if (tab.id === undefined) { if (tab.id === undefined) {
logger.error("Tab ID not found in browser action handler."); logger.error("Tab ID not found in browser action handler.");

View File

@@ -1,5 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="rgba(12, 12, 13, 0.8)" fill-opacity="0.5">
<path d="M12 1H4a3 3 0 0 0-3 3v2h2V4a1 1 0 0 1 1-1h8a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-2v2h2a3 3 0 0 0 3-3V4a3 3 0 0 0-3-3z"/>
<path d="M1 15v-2a2 2 0 0 1 2 2H1zM7 15h2a8 8 0 0 0-8-8v2a6 6 0 0 1 6 6z"/>
<path d="M1 12a3 3 0 0 1 3 3h2a5 5 0 0 0-5-5z"/>
</svg>

Before

Width:  |  Height:  |  Size: 377 B

View File

@@ -1,5 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="rgba(249, 249, 250, 0.8)" fill-opacity="0.5">
<path d="M12 1H4a3 3 0 0 0-3 3v2h2V4a1 1 0 0 1 1-1h8a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-2v2h2a3 3 0 0 0 3-3V4a3 3 0 0 0-3-3z"/>
<path d="M1 15v-2a2 2 0 0 1 2 2H1zM7 15h2a8 8 0 0 0-8-8v2a6 6 0 0 1 6 6z"/>
<path d="M1 12a3 3 0 0 1 3 3h2a5 5 0 0 0-5-5z"/>
</svg>

Before

Width:  |  Height:  |  Size: 380 B