queue/source/utilities/badge.ts

24 lines
637 B
TypeScript

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 action.setBadgeText({
text: queueLength === '0' ? '' : queueLength,
});
await action.setBadgeBackgroundColor({
color: '#2a2041',
});
if (import.meta.env.VITE_BROWSER === 'firefox') {
action.setBadgeTextColor({color: '#f2efff'});
}
}