debian-mirror-gitlab/app/assets/javascripts/whats_new/utils/notification.js
2023-04-23 21:23:45 +05:30

21 lines
759 B
JavaScript

export const STORAGE_KEY = 'display-whats-new-notification';
export const getVersionDigest = (appEl) => appEl.dataset.versionDigest;
export const setNotification = (appEl) => {
const versionDigest = getVersionDigest(appEl);
const notificationEl = document.querySelector('.header-help');
if (!notificationEl) return;
let notificationCountEl = notificationEl.querySelector('.js-whats-new-notification-count');
if (localStorage.getItem(STORAGE_KEY) === versionDigest) {
notificationEl.classList.remove('with-notifications');
if (notificationCountEl) {
notificationCountEl.parentElement.removeChild(notificationCountEl);
notificationCountEl = null;
}
} else {
notificationEl.classList.add('with-notifications');
}
};