From 456727c0e01b70d16713bc212f17125d011c4972 Mon Sep 17 00:00:00 2001 From: Lennart <18233294+lennart-k@users.noreply.github.com> Date: Sat, 9 Mar 2024 17:49:18 +0100 Subject: [PATCH] feature: Track current notification to replace it on track change --- src/preload.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/preload.ts b/src/preload.ts index 1e52461..885a012 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -28,6 +28,7 @@ let currentListenBrainzDelayId: ReturnType; let scrobbleWaitingForDelay = false; let wasJustPausedOrResumed = false; let currentMediaInfo: Options; +let currentNotification: Electron.Notification; const elements = { play: '*[data-test="play"]', @@ -359,7 +360,9 @@ function updateMediaInfo(options: Options, notify: boolean) { currentMediaInfo = options; ipcRenderer.send(globalEvents.updateInfo, options); if (settingsStore.get(settings.notifications) && notify) { - new Notification({ title: options.title, body: options.artists, icon: options.icon }).show(); + if (currentNotification) currentNotification.close(); + currentNotification = new Notification({ title: options.title, body: options.artists, icon: options.icon }); + currentNotification.show(); } updateMpris(options); updateListenBrainz(options);