mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2024-11-26 07:05:32 +01:00
fix: all discord fields are now padded to 2+ chars
This commit is contained in:
parent
e2a84e119a
commit
2c1c76d2d0
@ -4,6 +4,11 @@ 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
|
||||||
|
|
||||||
## [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
4
package-lock.json
generated
@ -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",
|
||||||
|
@ -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": {
|
||||||
|
@ -468,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/"
|
||||||
|
@ -14,11 +14,7 @@ export let rpc: Client;
|
|||||||
|
|
||||||
const observer = () => {
|
const observer = () => {
|
||||||
if (rpc) {
|
if (rpc) {
|
||||||
const showIdle = settingsStore.get<string, boolean>(settings.discord.showIdle) ?? true;
|
updateActivity();
|
||||||
if (mediaInfo.status === MediaStatus.paused && !showIdle) {
|
|
||||||
rpc.clearActivity();
|
|
||||||
} else
|
|
||||||
rpc.setActivity(getActivity());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -28,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 };
|
||||||
|
|
||||||
@ -58,23 +63,33 @@ const getActivity = (): Presence => {
|
|||||||
return { includeTimestamps, detailsPrefix, buttonText };
|
return { includeTimestamps, detailsPrefix, buttonText };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pad a string using spaces to at least 2 characters
|
||||||
|
* @param input string to pad with 2 characters
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function pad(input: string): string {
|
||||||
|
return input.padEnd(2, " ");
|
||||||
|
}
|
||||||
|
|
||||||
function setPresenceFromMediaInfo(detailsPrefix: string, buttonText: string) {
|
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) {
|
if (mediaInfo.url) {
|
||||||
presence.details = `${detailsPrefix}${mediaInfo.title}`;
|
presence.details = `${detailsPrefix}${title}`;
|
||||||
presence.state = mediaInfo.artists ? mediaInfo.artists : "unknown artist(s)";
|
presence.state = artists ? artists : "unknown artist(s)";
|
||||||
presence.largeImageKey = mediaInfo.image;
|
presence.largeImageKey = mediaInfo.image;
|
||||||
if (mediaInfo.album) {
|
if (album) {
|
||||||
if (mediaInfo.album.length < 2) { // Fix for DiscordRPC 2 character minimum
|
presence.largeImageText = album;
|
||||||
presence.largeImageText = mediaInfo.album + " ";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
presence.largeImageText = mediaInfo.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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,13 +114,13 @@ export const initRPC = () => {
|
|||||||
rpc.login({ clientId }).then(
|
rpc.login({ clientId }).then(
|
||||||
() => {
|
() => {
|
||||||
rpc.on("ready", () => {
|
rpc.on("ready", () => {
|
||||||
const showIdle = settingsStore.get<string, boolean>(settings.discord.showIdle) ?? true;
|
updateActivity();
|
||||||
if (mediaInfo.status === MediaStatus.paused && !showIdle) {
|
});
|
||||||
rpc.clearActivity();
|
|
||||||
} else
|
const { updateInfo, play, pause, playPause } = globalEvents;
|
||||||
rpc.setActivity(getActivity());
|
[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?");
|
||||||
|
@ -116,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" }]);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user