Skip to content

Commit

Permalink
fix: Notifications are now send at the end of the update process, all…
Browse files Browse the repository at this point in the history
…owing other events to happen sooner.
  • Loading branch information
Mastermindzh committed Aug 10, 2024
1 parent 2c1c76d commit 4f72e1b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fix issue #449 Discord RPC stuck on "Browsing Tidal".
- Fix issue #448 Add option to disable the discord rpc idle text
- Notifications are now send at the end of the update process, allowing other events to happen sooner.

## [5.15.0]

Expand Down
2 changes: 1 addition & 1 deletion src/features/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.1.0",
"info": {
"title": "TIDAL Hi-Fi API",
"version": "5.15.0",
"version": "5.16.0",
"description": "",
"license": {
"name": "MIT",
Expand Down
32 changes: 22 additions & 10 deletions src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,18 +394,30 @@ function updateMediaInfo(mediaInfo: MediaInfo, notify: boolean) {
if (mediaInfo) {
currentMediaInfo = mediaInfo;
ipcRenderer.send(globalEvents.updateInfo, mediaInfo);
if (settingsStore.get(settings.notifications) && notify) {
if (currentNotification) currentNotification.close();
currentNotification = new Notification({
title: mediaInfo.title,
body: mediaInfo.artists,
icon: mediaInfo.icon,
});
currentNotification.show();
}

updateMpris(mediaInfo);
updateListenBrainz(mediaInfo);
if (notify) {
sendNotification(mediaInfo);
}
}
}

/**
* send a desktop notification if enabled in settings
* @param mediaInfo
* @param notify Whether to notify
*/
async function sendNotification(mediaInfo: MediaInfo) {
if (settingsStore.get(settings.notifications)) {
if (currentNotification) {
currentNotification.close();
}
currentNotification = new Notification({
title: mediaInfo.title,
body: mediaInfo.artists,
icon: mediaInfo.icon,
});
currentNotification.show();
}
}

Expand Down

0 comments on commit 4f72e1b

Please sign in to comment.