Make updateBadge Chromium compatible.

This commit is contained in:
Bauke 2022-03-20 19:23:59 +01:00
parent bf8712dbf6
commit 8d99e8200b
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
1 changed files with 14 additions and 4 deletions

View File

@ -3,11 +3,21 @@ import browser from 'webextension-polyfill';
import {Settings} from '../settings/settings.js';
export async function updateBadge(settings: Settings): Promise<void> {
let action: browser.Action.Static = browser.browserAction;
if (import.meta.env.VITE_BROWSER === 'chromium') {
action = browser.action;
}
const queueLength = settings.queue.length.toString();
await browser.browserAction.setBadgeText({
text: queueLength === '0' ? null : queueLength,
await action.setBadgeText({
text: queueLength === '0' ? '' : queueLength,
});
await browser.browserAction.setBadgeBackgroundColor({color: '#2a2041'});
browser.browserAction.setBadgeTextColor({color: '#f2efff'});
await action.setBadgeBackgroundColor({
color: '#2a2041',
});
if (import.meta.env.VITE_BROWSER === 'firefox') {
action.setBadgeTextColor({color: '#f2efff'});
}
}