diff --git a/package-lock.json b/package-lock.json index b19fbb5..64263a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,7 @@ "@typescript-eslint/eslint-plugin": "^7.16.0", "@typescript-eslint/parser": "^7.15.0", "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", "eslint": "^8.57.0", "js-yaml": "^4.1.0", diff --git a/src/scripts/discord.ts b/src/scripts/discord.ts index 6fc06e2..a61c40b 100644 --- a/src/scripts/discord.ts +++ b/src/scripts/discord.ts @@ -12,6 +12,8 @@ const clientId = "833617820704440341"; export let rpc: DRPC.Client; +const ACTIVITY_LISTENING = 2; + const observer = () => { if (rpc) { updateActivity(); @@ -20,7 +22,7 @@ const observer = () => { const defaultPresence = { largeImageKey: "tidal-hifi-icon", - largeImageText: `TIDAL Hi-Fi ${app.getVersion()}`, + largeImageText: `Tidal`, instance: false, }; @@ -36,7 +38,7 @@ const updateActivity = () => { const getActivity = (): DRPC.Presence => { const presence: DRPC.Presence = { ...defaultPresence }; - presence.type = DRPC.ActivityTypes.LISTENING + presence.type = ACTIVITY_LISTENING; if (mediaInfo.status === MediaStatus.paused) { presence.details = @@ -52,13 +54,14 @@ const getActivity = (): DRPC.Presence => { settingsStore.get(settings.discord.usingText) ?? "Playing media on TIDAL"; } } + return presence; function getFromStore() { const includeTimestamps = settingsStore.get(settings.discord.includeTimestamps) ?? true; const detailsPrefix = - settingsStore.get(settings.discord.detailsPrefix) ?? "Listening to "; + settingsStore.get(settings.discord.detailsPrefix) ?? ""; const buttonText = settingsStore.get(settings.discord.buttonText) ?? "Play on TIDAL"; @@ -100,12 +103,13 @@ const getActivity = (): DRPC.Presence => { const currentSeconds = convertDurationToSeconds(mediaInfo.current); const durationSeconds = convertDurationToSeconds(mediaInfo.duration); const date = new Date(); - const now = (date.getTime() / 1000) | 0; - const remaining = date.setSeconds(date.getSeconds() + (durationSeconds - currentSeconds)); - presence.startTimestamp = now; - presence.endTimestamp = remaining; + const now = Math.floor(date.getTime() / 1000); + const startTimestamp = now - currentSeconds; + const endTimestamp = startTimestamp + durationSeconds; + presence.startTimestamp = startTimestamp; + presence.endTimestamp = endTimestamp; } - } + } }; /** diff --git a/src/scripts/settings.ts b/src/scripts/settings.ts index 4e5323a..8e7b296 100644 --- a/src/scripts/settings.ts +++ b/src/scripts/settings.ts @@ -47,7 +47,7 @@ export const settingsStore = new Store({ idleText: "Browsing Tidal", usingText: "Playing media on TIDAL", includeTimestamps: true, - detailsPrefix: "Listening to ", + detailsPrefix: "", buttonText: "Play on Tidal", }, ListenBrainz: {