Merge pull request #456 from Mastermindzh/develop

Develop
This commit is contained in:
Rick van Lieshout 2024-08-10 14:49:42 +02:00 committed by GitHub
commit ef13933c66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 92 additions and 26 deletions

View File

@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [5.16.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] ## [5.15.0]
- Added all missing swagger/openApi info with the help of [Times-Z](https://github.com/Times-Z) - Added all missing swagger/openApi info with the help of [Times-Z](https://github.com/Times-Z)

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "tidal-hifi", "name": "tidal-hifi",
"version": "5.15.0", "version": "5.16.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "tidal-hifi", "name": "tidal-hifi",
"version": "5.15.0", "version": "5.16.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@electron/remote": "^2.1.2", "@electron/remote": "^2.1.2",

View File

@ -1,6 +1,6 @@
{ {
"name": "tidal-hifi", "name": "tidal-hifi",
"version": "5.15.0", "version": "5.16.0",
"description": "Tidal on Electron with widevine(hifi) support", "description": "Tidal on Electron with widevine(hifi) support",
"main": "ts-dist/main.js", "main": "ts-dist/main.js",
"scripts": { "scripts": {

View File

@ -30,6 +30,7 @@ export const settings = {
buttonText: "discord.buttonText", buttonText: "discord.buttonText",
includeTimestamps: "discord.includeTimestamps", includeTimestamps: "discord.includeTimestamps",
showSong: "discord.showSong", showSong: "discord.showSong",
showIdle: "discord.showIdle",
idleText: "discord.idleText", idleText: "discord.idleText",
usingText: "discord.usingText", usingText: "discord.usingText",
}, },

View File

@ -2,7 +2,7 @@
"openapi": "3.1.0", "openapi": "3.1.0",
"info": { "info": {
"title": "TIDAL Hi-Fi API", "title": "TIDAL Hi-Fi API",
"version": "5.15.0", "version": "5.16.0",
"description": "", "description": "",
"license": { "license": {
"name": "MIT", "name": "MIT",

View File

@ -58,6 +58,7 @@ let adBlock: HTMLInputElement,
discord_include_timestamps: HTMLInputElement, discord_include_timestamps: HTMLInputElement,
discord_button_text: HTMLInputElement, discord_button_text: HTMLInputElement,
discord_show_song: HTMLInputElement, discord_show_song: HTMLInputElement,
discord_show_idle: HTMLInputElement,
discord_idle_text: HTMLInputElement, discord_idle_text: HTMLInputElement,
discord_using_text: HTMLInputElement; discord_using_text: HTMLInputElement;
@ -151,6 +152,7 @@ function refreshSettings() {
discord_include_timestamps.checked = settingsStore.get(settings.discord.includeTimestamps); discord_include_timestamps.checked = settingsStore.get(settings.discord.includeTimestamps);
discord_button_text.value = settingsStore.get(settings.discord.buttonText); discord_button_text.value = settingsStore.get(settings.discord.buttonText);
discord_show_song.checked = settingsStore.get(settings.discord.showSong); discord_show_song.checked = settingsStore.get(settings.discord.showSong);
discord_show_idle.checked = settingsStore.get(settings.discord.showIdle);
discord_idle_text.value = settingsStore.get(settings.discord.idleText); discord_idle_text.value = settingsStore.get(settings.discord.idleText);
discord_using_text.value = settingsStore.get(settings.discord.usingText); discord_using_text.value = settingsStore.get(settings.discord.usingText);
@ -269,6 +271,7 @@ window.addEventListener("DOMContentLoaded", () => {
listenbrainz_delay = get("listenbrainz_delay"); listenbrainz_delay = get("listenbrainz_delay");
discord_button_text = get("discord_button_text"); discord_button_text = get("discord_button_text");
discord_show_song = get("discord_show_song"); discord_show_song = get("discord_show_song");
discord_show_idle = get("discord_show_idle");
discord_using_text = get("discord_using_text"); discord_using_text = get("discord_using_text");
discord_idle_text = get("discord_idle_text"); discord_idle_text = get("discord_idle_text");
@ -312,6 +315,7 @@ window.addEventListener("DOMContentLoaded", () => {
settings.discord.showSong, settings.discord.showSong,
switchesWithSettings.discord_show_song switchesWithSettings.discord_show_song
); );
addInputListener(discord_show_idle, settings.discord.showIdle);
addInputListener(discord_idle_text, settings.discord.idleText); addInputListener(discord_idle_text, settings.discord.idleText);
addInputListener(discord_using_text, settings.discord.usingText); addInputListener(discord_using_text, settings.discord.usingText);
}); });

View File

@ -227,6 +227,17 @@
</div> </div>
<div id="discord_options"> <div id="discord_options">
<div class="group__option" class="hidden">
<div class="group__description">
<h4>Show Idle Text</h4>
<p>Should the idle text be shown when idle?</p>
</div>
<label class="switch">
<input id="discord_show_idle" type="checkbox" />
<span class="switch__slider"></span>
</label>
</div>
<div class="group__option" class="hidden"> <div class="group__option" class="hidden">
<div class="group__description"> <div class="group__description">
<h4>Idle Text</h4> <h4>Idle Text</h4>
@ -457,7 +468,7 @@
<h4>TIDAL Hi-Fi</h4> <h4>TIDAL Hi-Fi</h4>
<div class="about-section__version"> <div class="about-section__version">
<a target="_blank" rel="noopener" <a target="_blank" rel="noopener"
href="https://github.com/Mastermindzh/tidal-hifi/releases/tag/5.15.0">5.15.0</a> href="https://github.com/Mastermindzh/tidal-hifi/releases/tag/5.16.0">5.16.0</a>
</div> </div>
<div class="about-section__links"> <div class="about-section__links">
<a target="_blank" rel="noopener" href="https://github.com/mastermindzh/tidal-hifi/" <a target="_blank" rel="noopener" href="https://github.com/mastermindzh/tidal-hifi/"

View File

@ -394,8 +394,24 @@ function updateMediaInfo(mediaInfo: MediaInfo, notify: boolean) {
if (mediaInfo) { if (mediaInfo) {
currentMediaInfo = mediaInfo; currentMediaInfo = mediaInfo;
ipcRenderer.send(globalEvents.updateInfo, mediaInfo); ipcRenderer.send(globalEvents.updateInfo, mediaInfo);
if (settingsStore.get(settings.notifications) && notify) { updateMpris(mediaInfo);
if (currentNotification) currentNotification.close(); 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({ currentNotification = new Notification({
title: mediaInfo.title, title: mediaInfo.title,
body: mediaInfo.artists, body: mediaInfo.artists,
@ -403,10 +419,6 @@ function updateMediaInfo(mediaInfo: MediaInfo, notify: boolean) {
}); });
currentNotification.show(); currentNotification.show();
} }
updateMpris(mediaInfo);
updateListenBrainz(mediaInfo);
}
} }
function addMPRIS() { function addMPRIS() {

View File

@ -14,7 +14,7 @@ export let rpc: Client;
const observer = () => { const observer = () => {
if (rpc) { if (rpc) {
rpc.setActivity(getActivity()); updateActivity();
} }
}; };
@ -24,6 +24,15 @@ const defaultPresence = {
instance: false, instance: false,
}; };
const updateActivity = () => {
const showIdle = settingsStore.get<string, boolean>(settings.discord.showIdle) ?? true;
if (mediaInfo.status === MediaStatus.paused && !showIdle) {
rpc.clearActivity();
} else {
rpc.setActivity(getActivity());
}
};
const getActivity = (): Presence => { const getActivity = (): Presence => {
const presence: Presence = { ...defaultPresence }; const presence: Presence = { ...defaultPresence };
@ -54,18 +63,33 @@ const getActivity = (): Presence => {
return { includeTimestamps, detailsPrefix, buttonText }; return { includeTimestamps, detailsPrefix, buttonText };
} }
function setPresenceFromMediaInfo(detailsPrefix: string, buttonText: string) { /**
if (mediaInfo.url) { * Pad a string using spaces to at least 2 characters
presence.details = `${detailsPrefix}${mediaInfo.title}`; * @param input string to pad with 2 characters
presence.state = mediaInfo.artists ? mediaInfo.artists : "unknown artist(s)"; * @returns
presence.largeImageKey = mediaInfo.image; */
if (mediaInfo.album) { function pad(input: string): string {
presence.largeImageText = mediaInfo.album; return input.padEnd(2, " ");
} }
function setPresenceFromMediaInfo(detailsPrefix: string, buttonText: string) {
// discord requires a minimum of 2 characters
const title = pad(mediaInfo.title);
const album = pad(mediaInfo.album);
const artists = pad(mediaInfo.artists);
if (mediaInfo.url) {
presence.details = `${detailsPrefix}${title}`;
presence.state = artists ? artists : "unknown artist(s)";
presence.largeImageKey = mediaInfo.image;
if (album) {
presence.largeImageText = album;
}
presence.buttons = [{ label: buttonText, url: mediaInfo.url }]; presence.buttons = [{ label: buttonText, url: mediaInfo.url }];
} else { } else {
presence.details = `Watching ${mediaInfo.title}`; presence.details = `Watching ${title}`;
presence.state = mediaInfo.artists; presence.state = artists;
} }
} }
@ -90,9 +114,13 @@ export const initRPC = () => {
rpc.login({ clientId }).then( rpc.login({ clientId }).then(
() => { () => {
rpc.on("ready", () => { rpc.on("ready", () => {
rpc.setActivity(getActivity()); updateActivity();
});
const { updateInfo, play, pause, playPause } = globalEvents;
[updateInfo, play, pause, playPause].forEach((status) => {
ipcMain.on(status, observer);
}); });
ipcMain.on(globalEvents.updateInfo, observer);
}, },
() => { () => {
Logger.log("Can't connect to Discord, is it running?"); Logger.log("Can't connect to Discord, is it running?");

View File

@ -43,6 +43,7 @@ export const settingsStore = new Store({
enableDiscord: false, enableDiscord: false,
discord: { discord: {
showSong: true, showSong: true,
showIdle: true,
idleText: "Browsing Tidal", idleText: "Browsing Tidal",
usingText: "Playing media on TIDAL", usingText: "Playing media on TIDAL",
includeTimestamps: true, includeTimestamps: true,
@ -115,6 +116,9 @@ export const settingsStore = new Store({
{ key: settings.advanced.tidalUrl, value: "https://listen.tidal.com" }, { key: settings.advanced.tidalUrl, value: "https://listen.tidal.com" },
]); ]);
}, },
"5.16.0": (migrationStore) => {
buildMigration("5.16.0", migrationStore, [{ key: settings.discord.showIdle, value: "true" }]);
},
}, },
}); });