Fix: Adds favicon badge for notification alert. (#2079)

* Adds favicon badge for notification alert.
This commit is contained in:
Sivin Varghese 2021-04-13 19:25:19 +05:30 committed by GitHub
parent 4387736f1a
commit a14e8ba250
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 28 additions and 3 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;
});
}
});
};