mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2024-11-22 21:42:46 +01:00
Fixed impl
This commit is contained in:
parent
1a0c15e17f
commit
b1830f5684
2
package-lock.json
generated
2
package-lock.json
generated
@ -32,7 +32,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^7.16.0",
|
"@typescript-eslint/eslint-plugin": "^7.16.0",
|
||||||
"@typescript-eslint/parser": "^7.15.0",
|
"@typescript-eslint/parser": "^7.15.0",
|
||||||
"copyfiles": "^2.4.1",
|
"copyfiles": "^2.4.1",
|
||||||
"electron": "git+https://github.com/castlabs/electron-releases#v33.1.0+wvcus",
|
"electron": "git+https://github.com/castlabs/electron-releases#v32.0.0+wvcus",
|
||||||
"electron-builder": "~24.9.4",
|
"electron-builder": "~24.9.4",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
|
@ -12,6 +12,8 @@ const clientId = "833617820704440341";
|
|||||||
|
|
||||||
export let rpc: DRPC.Client;
|
export let rpc: DRPC.Client;
|
||||||
|
|
||||||
|
const ACTIVITY_LISTENING = 2;
|
||||||
|
|
||||||
const observer = () => {
|
const observer = () => {
|
||||||
if (rpc) {
|
if (rpc) {
|
||||||
updateActivity();
|
updateActivity();
|
||||||
@ -20,7 +22,7 @@ const observer = () => {
|
|||||||
|
|
||||||
const defaultPresence = {
|
const defaultPresence = {
|
||||||
largeImageKey: "tidal-hifi-icon",
|
largeImageKey: "tidal-hifi-icon",
|
||||||
largeImageText: `TIDAL Hi-Fi ${app.getVersion()}`,
|
largeImageText: `Tidal`,
|
||||||
instance: false,
|
instance: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -36,7 +38,7 @@ const updateActivity = () => {
|
|||||||
const getActivity = (): DRPC.Presence => {
|
const getActivity = (): DRPC.Presence => {
|
||||||
const presence: DRPC.Presence = { ...defaultPresence };
|
const presence: DRPC.Presence = { ...defaultPresence };
|
||||||
|
|
||||||
presence.type = DRPC.ActivityTypes.LISTENING
|
presence.type = ACTIVITY_LISTENING;
|
||||||
|
|
||||||
if (mediaInfo.status === MediaStatus.paused) {
|
if (mediaInfo.status === MediaStatus.paused) {
|
||||||
presence.details =
|
presence.details =
|
||||||
@ -52,13 +54,14 @@ const getActivity = (): DRPC.Presence => {
|
|||||||
settingsStore.get<string, string>(settings.discord.usingText) ?? "Playing media on TIDAL";
|
settingsStore.get<string, string>(settings.discord.usingText) ?? "Playing media on TIDAL";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return presence;
|
return presence;
|
||||||
|
|
||||||
function getFromStore() {
|
function getFromStore() {
|
||||||
const includeTimestamps =
|
const includeTimestamps =
|
||||||
settingsStore.get<string, boolean>(settings.discord.includeTimestamps) ?? true;
|
settingsStore.get<string, boolean>(settings.discord.includeTimestamps) ?? true;
|
||||||
const detailsPrefix =
|
const detailsPrefix =
|
||||||
settingsStore.get<string, string>(settings.discord.detailsPrefix) ?? "Listening to ";
|
settingsStore.get<string, string>(settings.discord.detailsPrefix) ?? "";
|
||||||
const buttonText =
|
const buttonText =
|
||||||
settingsStore.get<string, string>(settings.discord.buttonText) ?? "Play on TIDAL";
|
settingsStore.get<string, string>(settings.discord.buttonText) ?? "Play on TIDAL";
|
||||||
|
|
||||||
@ -100,10 +103,11 @@ const getActivity = (): DRPC.Presence => {
|
|||||||
const currentSeconds = convertDurationToSeconds(mediaInfo.current);
|
const currentSeconds = convertDurationToSeconds(mediaInfo.current);
|
||||||
const durationSeconds = convertDurationToSeconds(mediaInfo.duration);
|
const durationSeconds = convertDurationToSeconds(mediaInfo.duration);
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const now = (date.getTime() / 1000) | 0;
|
const now = Math.floor(date.getTime() / 1000);
|
||||||
const remaining = date.setSeconds(date.getSeconds() + (durationSeconds - currentSeconds));
|
const startTimestamp = now - currentSeconds;
|
||||||
presence.startTimestamp = now;
|
const endTimestamp = startTimestamp + durationSeconds;
|
||||||
presence.endTimestamp = remaining;
|
presence.startTimestamp = startTimestamp;
|
||||||
|
presence.endTimestamp = endTimestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -47,7 +47,7 @@ export const settingsStore = new Store({
|
|||||||
idleText: "Browsing Tidal",
|
idleText: "Browsing Tidal",
|
||||||
usingText: "Playing media on TIDAL",
|
usingText: "Playing media on TIDAL",
|
||||||
includeTimestamps: true,
|
includeTimestamps: true,
|
||||||
detailsPrefix: "Listening to ",
|
detailsPrefix: "",
|
||||||
buttonText: "Play on Tidal",
|
buttonText: "Play on Tidal",
|
||||||
},
|
},
|
||||||
ListenBrainz: {
|
ListenBrainz: {
|
||||||
|
Loading…
Reference in New Issue
Block a user