icon change only applies to a supported tab

This commit is contained in:
buzz-lightsnack-2007 2024-04-27 16:33:49 +08:00
parent 7e07a9e2fd
commit 4581ec76f3

View file

@ -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);
}
}