chore: Refactor audio notification helper (#6148)

This commit is contained in:
Pranav Raj S
2022-12-29 20:01:14 -08:00
committed by GitHub
parent 11f6e6bc61
commit cd3b6ebf28
10 changed files with 131 additions and 273 deletions

View File

@@ -0,0 +1,21 @@
export const showBadgeOnFavicon = () => {
const favicons = document.querySelectorAll('.favicon');
favicons.forEach(favicon => {
const newFileName = `/favicon-badge-${favicon.sizes[[0]]}.png`;
favicon.href = newFileName;
});
};
export const initFaviconSwitcher = () => {
const favicons = document.querySelectorAll('.favicon');
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
favicons.forEach(favicon => {
const oldFileName = `/favicon-${favicon.sizes[[0]]}.png`;
favicon.href = oldFileName;
});
}
});
};