Update electron to 32.0.1
This commit is contained in:
parent
ed95c8959f
commit
3c25092f50
14 changed files with 104 additions and 544 deletions
|
@ -4,45 +4,32 @@
|
|||
import { ipcMain as ipc } from 'electron';
|
||||
import type { IpcMainInvokeEvent } from 'electron';
|
||||
|
||||
// These dependencies don't export typescript properly
|
||||
// https://github.com/NodeRT/NodeRT/issues/167
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
import { XmlDocument } from '@nodert-win10-rs4/windows.data.xml.dom';
|
||||
import {
|
||||
ToastNotification,
|
||||
ToastNotificationManager,
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
} from '@nodert-win10-rs4/windows.ui.notifications';
|
||||
Notifier,
|
||||
sendDummyKeystroke,
|
||||
} from '@indutny/simple-windows-notifications';
|
||||
|
||||
import * as log from '../ts/logging/log';
|
||||
import { AUMID } from './startup_config';
|
||||
import type { WindowsNotificationData } from '../ts/services/notifications';
|
||||
import { renderWindowsToast } from './renderWindowsToast';
|
||||
|
||||
export { sendDummyKeystroke } from '@signalapp/windows-dummy-keystroke';
|
||||
export { sendDummyKeystroke };
|
||||
|
||||
const NOTIFICATION_GROUP = 'group';
|
||||
const NOTIFICATION_TAG = 'tag';
|
||||
const notifier = new Notifier(AUMID);
|
||||
|
||||
const NOTIFICATION_ID = {
|
||||
group: 'group',
|
||||
tag: 'tag',
|
||||
};
|
||||
|
||||
ipc.handle(
|
||||
'windows-notifications:show',
|
||||
(_event: IpcMainInvokeEvent, data: WindowsNotificationData) => {
|
||||
try {
|
||||
// First, clear all previous notifications - we want just one notification at a time
|
||||
clearAllNotifications();
|
||||
|
||||
const xmlDocument = new XmlDocument();
|
||||
xmlDocument.loadXml(renderWindowsToast(data));
|
||||
|
||||
const toast = new ToastNotification(xmlDocument);
|
||||
toast.tag = NOTIFICATION_TAG;
|
||||
toast.group = NOTIFICATION_GROUP;
|
||||
|
||||
const notifier = ToastNotificationManager.createToastNotifier(AUMID);
|
||||
notifier.show(toast);
|
||||
notifier.remove(NOTIFICATION_ID);
|
||||
notifier.show(renderWindowsToast(data), NOTIFICATION_ID);
|
||||
} catch (error) {
|
||||
log.error(
|
||||
`Windows Notifications: Failed to show notification: ${error.stack}`
|
||||
|
@ -53,18 +40,10 @@ ipc.handle(
|
|||
|
||||
ipc.handle('windows-notifications:clear-all', () => {
|
||||
try {
|
||||
clearAllNotifications();
|
||||
notifier.remove(NOTIFICATION_ID);
|
||||
} catch (error) {
|
||||
log.error(
|
||||
`Windows Notifications: Failed to clear notifications: ${error.stack}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
function clearAllNotifications() {
|
||||
ToastNotificationManager.history.remove(
|
||||
NOTIFICATION_TAG,
|
||||
NOTIFICATION_GROUP,
|
||||
AUMID
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue