feature: Track current notification to replace it on track change

This commit is contained in:
Lennart 2024-03-09 17:49:18 +01:00
parent 76769dfab3
commit 456727c0e0
No known key found for this signature in database
GPG Key ID: A739E9B56656CBDE

View File

@ -28,6 +28,7 @@ let currentListenBrainzDelayId: ReturnType<typeof setTimeout>;
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);