notification: remove dead code (notification class always present)
This commit is contained in:
@@ -7,56 +7,34 @@ import { notifications } from '../core/notifications.js';
|
|||||||
|
|
||||||
const uiNotifications = {
|
const uiNotifications = {
|
||||||
show(title, message) {
|
show(title, message) {
|
||||||
if (notifications && typeof notifications.addNotification === 'function') {
|
const normalizedTitle = String(title || '').toLowerCase();
|
||||||
const normalizedTitle = String(title || '').toLowerCase();
|
let icon = 'fa-info-circle';
|
||||||
let icon = 'fa-info-circle';
|
let iconClass = 'upload';
|
||||||
let iconClass = 'upload';
|
|
||||||
|
|
||||||
if (normalizedTitle.includes('error') || normalizedTitle.includes('failed') || normalizedTitle.includes('fail')) {
|
if (normalizedTitle.includes('error') || normalizedTitle.includes('failed') || normalizedTitle.includes('fail')) {
|
||||||
icon = 'fa-exclamation-circle';
|
icon = 'fa-exclamation-circle';
|
||||||
iconClass = 'error';
|
iconClass = 'error';
|
||||||
} else if (normalizedTitle.includes('favorite') || normalizedTitle.includes('favorit') || normalizedTitle.includes('fav')) {
|
} else if (normalizedTitle.includes('favorite') || normalizedTitle.includes('favorit') || normalizedTitle.includes('fav')) {
|
||||||
icon = 'fa-star';
|
icon = 'fa-star';
|
||||||
iconClass = 'success';
|
iconClass = 'success';
|
||||||
} else if (
|
} else if (
|
||||||
normalizedTitle.includes('delete') ||
|
normalizedTitle.includes('delete') ||
|
||||||
normalizedTitle.includes('removed') ||
|
normalizedTitle.includes('removed') ||
|
||||||
normalizedTitle.includes('trash') ||
|
normalizedTitle.includes('trash') ||
|
||||||
normalizedTitle.includes('rename') ||
|
normalizedTitle.includes('rename') ||
|
||||||
normalizedTitle.includes('complete')
|
normalizedTitle.includes('complete')
|
||||||
) {
|
) {
|
||||||
icon = 'fa-check-circle';
|
icon = 'fa-check-circle';
|
||||||
iconClass = 'success';
|
iconClass = 'success';
|
||||||
}
|
|
||||||
|
|
||||||
notifications.addNotification({
|
|
||||||
icon,
|
|
||||||
iconClass,
|
|
||||||
title: title || '',
|
|
||||||
text: message || ''
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let notification = document.querySelector('.notification');
|
notifications.addNotification({
|
||||||
if (!notification) {
|
icon,
|
||||||
notification = document.createElement('div');
|
iconClass,
|
||||||
notification.classList.add('notification', 'hidden');
|
title: title || '',
|
||||||
notification.innerHTML = `
|
text: message || ''
|
||||||
<div class="notification-title">${title}</div>
|
});
|
||||||
<div class="notification-message">${message}</div>
|
return;
|
||||||
`;
|
|
||||||
document.body.appendChild(notification);
|
|
||||||
} else {
|
|
||||||
notification.querySelector('.notification-title').textContent = title;
|
|
||||||
notification.querySelector('.notification-message').textContent = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
notification.classList.remove('hidden');
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
notification.classList.add('hidden');
|
|
||||||
}, 5000);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user