Notification Fade Out

This commit is contained in:
Jean Ouina 2020-06-10 23:47:26 +02:00
parent 9afa4cc913
commit 9776b4f4d3
2 changed files with 8 additions and 1 deletions

View File

@ -248,7 +248,6 @@ let childModule = BDModules.get(e => e.childContainer)[0]
function renderToElements(id, result, filename){
const div = document.getElementById(id)
if(!div || div.childNodes.length > 0)return // already certified/div does not exist anymore.
// TODO: implements suspect plugins.
if(!flowerStarModule)flowerStarModule = BDModules.get(e => e.flowerStarContainer)[0]
if(!childModule)childModule = BDModules.get(e => e.childContainer)[0]

View File

@ -123,6 +123,10 @@ function handleNotificationsClear() {
function handleNotificationShow(e, notification) {
notifications.push(notification);
updateNotifications();
setTimeout(() => {
if(!notifications.find(e => e.id === notification.id))return
handleNotificationClose(null, notification.id)
}, 3000)
}
function handleNotificationClick(e, notificationId) {
@ -130,12 +134,16 @@ function handleNotificationClick(e, notificationId) {
events.emit(NOTIFICATION_CLICK);
}
let isClosing = []
function handleNotificationClose(e, notificationId) {
if(isClosing.includes(notificationId))return
if (notificationWindow) {
webContentsSend(notificationWindow, 'FADE_OUT', notificationId);
}
isClosing.push(notificationId)
setTimeout(() => {
notifications = notifications.filter(notification => notification.id !== notificationId);
isClosing = isClosing.filter(e => e.id !== notificationId)
updateNotifications();
}, VARIABLES.outDuration);
}