From 4581ec76f3b7d6d466ea50c5f674927ee01c1a84 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sat, 27 Apr 2024 16:33:49 +0800 Subject: [PATCH] icon change only applies to a supported tab --- scripts/GUI/entrypoints/icons.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/GUI/entrypoints/icons.js b/scripts/GUI/entrypoints/icons.js index 932a080..60daa8f 100644 --- a/scripts/GUI/entrypoints/icons.js +++ b/scripts/GUI/entrypoints/icons.js @@ -1,21 +1,34 @@ import BrowserIcon from '/scripts/GUI/extensionIcon.js'; import Image from '/scripts/mapping/image.js'; +import Tabs from '/scripts/GUI/tabs.js'; import {session} from '/scripts/secretariat.js'; class IconIndicator { + /* + Update the icon. + + @param {string} state The state to update the icon to. + */ + static update(state = false) { + (Image.get(((state) ? `default` : 'disabled'))).then((ICON) => { + (Tabs.query(null, 0)).then((DATA) => { + BrowserIcon.set({"Icon": ICON}, {"tabId": DATA.id}); + }); + }) + } + /* Indicate that the website is supported through icon change. */ static async enable() { - // Set default enabled icon. - BrowserIcon.set({"Icon": await Image.get('default')}); + IconIndicator.update(true); } /* Indicate that the website isn't supported through icon change. */ static async disable() { - BrowserIcon.setIcon({"Icon": await Image.get('disabled')}); + // IconIndicator.update(false); } }