debian-mirror-gitlab/app/assets/javascripts/whats_new/utils/notification.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
727 B
JavaScript
Raw Normal View History

2021-04-29 21:17:54 +05:30
export const STORAGE_KEY = 'display-whats-new-notification';
2022-07-23 23:45:48 +05:30
export const getVersionDigest = (appEl) => appEl.dataset.versionDigest;
2021-02-22 17:27:13 +05:30
2021-03-08 18:12:59 +05:30
export const setNotification = (appEl) => {
2021-04-29 21:17:54 +05:30
const versionDigest = getVersionDigest(appEl);
2021-02-22 17:27:13 +05:30
const notificationEl = document.querySelector('.header-help');
let notificationCountEl = notificationEl.querySelector('.js-whats-new-notification-count');
2021-04-29 21:17:54 +05:30
if (localStorage.getItem(STORAGE_KEY) === versionDigest) {
2021-02-22 17:27:13 +05:30
notificationEl.classList.remove('with-notifications');
if (notificationCountEl) {
notificationCountEl.parentElement.removeChild(notificationCountEl);
notificationCountEl = null;
}
} else {
notificationEl.classList.add('with-notifications');
}
};