Make updateBadge Chromium compatible.
This commit is contained in:
parent
bf8712dbf6
commit
8d99e8200b
|
@ -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'});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue