feature/IO-3702-ESPD-UI-AND-FIXES - Stage 2
This commit is contained in:
26
src/main/util/notification.ts
Normal file
26
src/main/util/notification.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Notification, type NotificationConstructorOptions } from "electron";
|
||||
import log from "electron-log/main";
|
||||
|
||||
function createNotification(
|
||||
options: NotificationConstructorOptions,
|
||||
context = options.title,
|
||||
): Notification {
|
||||
const notification = new Notification(options);
|
||||
|
||||
notification.on("failed", (_event, error) => {
|
||||
log.warn(`Notification failed${context ? ` (${context})` : ""}:`, error);
|
||||
});
|
||||
|
||||
return notification;
|
||||
}
|
||||
|
||||
function showNotification(
|
||||
options: NotificationConstructorOptions,
|
||||
context?: string,
|
||||
): Notification {
|
||||
const notification = createNotification(options, context);
|
||||
notification.show();
|
||||
return notification;
|
||||
}
|
||||
|
||||
export { createNotification, showNotification };
|
||||
Reference in New Issue
Block a user