Fix: Adds favicon badge for notification alert. (#2079)
* Adds favicon badge for notification alert.
This commit is contained in:
parent
4387736f1a
commit
a14e8ba250
7 changed files with 28 additions and 3 deletions
21
app/javascript/shared/helpers/faviconHelper.js
Normal file
21
app/javascript/shared/helpers/faviconHelper.js
Normal 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;
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue