From 4f72e1b35df17c10b04e310c2d15d41e2fdca44c Mon Sep 17 00:00:00 2001 From: Rick van Lieshout Date: Sat, 10 Aug 2024 14:46:08 +0200 Subject: [PATCH] fix: Notifications are now send at the end of the update process, allowing other events to happen sooner. --- CHANGELOG.md | 1 + src/features/api/swagger.json | 2 +- src/preload.ts | 32 ++++++++++++++++++++++---------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a15b799..a63b2a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] diff --git a/src/features/api/swagger.json b/src/features/api/swagger.json index 01d3d08..740d696 100644 --- a/src/features/api/swagger.json +++ b/src/features/api/swagger.json @@ -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", diff --git a/src/preload.ts b/src/preload.ts index e1661c3..814044b 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -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(); } }