Skip to content

Commit

Permalink
Merge pull request #364 from lennart-k/master
Browse files Browse the repository at this point in the history
feature: Track current notification to replace it on track change
  • Loading branch information
Mastermindzh committed Mar 24, 2024
2 parents 5ff2cc6 + 456727c commit 5b5b6ec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]',
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5b5b6ec

Please sign in to comment.