Skip to content

Commit

Permalink
electron crash issue - fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
JasminDreasond committed Aug 16, 2023
1 parent a52089b commit cf8cd30
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions electron/main/notification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,22 @@ export default function startNotifications(ipcMain) {
};

const closeNoti = (event) => {
if (notifications[tag]) {
try {
if (notifications[tag]) {

e.reply('tiny-notification-close', { tag, event: filterEvent(event) });
delete notifications[tag];
e.reply('tiny-notification-close', { tag, event: filterEvent(event) });

if (data.iconFromWeb && typeof data.iconFile === 'string') {
if (data.iconFromWeb && typeof data.iconFile === 'string') {

const filePath = path.join(tempFolderNoti, `./${data.iconFile}`);
if (fs.existsSync(filePath)) fs.unlinkSync(filePath);
const filePath = path.join(tempFolderNoti, `./${data.iconFile}`);
if (fs.existsSync(filePath)) fs.unlinkSync(filePath);

}

delete notifications[tag];
}

}
} catch (err) {
console.error(err);
}
};

Expand All @@ -85,12 +88,7 @@ export default function startNotifications(ipcMain) {
notifications[tag].on('close', closeNoti);

// Close
setTimeout(() => {
if (notifications[tag]) { notifications[tag].close(); } else {
closeNoti({});
}
}, timeout);

setTimeout(() => closeNoti({}), timeout);
e.reply('tiny-notification-create-confirm', { tag, isSupported: Notification.isSupported() });

};
Expand Down

0 comments on commit cf8cd30

Please sign in to comment.