fix: discord presence not clearing after pausing player (#973)

* add show rich presence when paused option
This commit is contained in:
Lyall 2025-06-28 21:46:12 +01:00 committed by GitHub
parent d922d8b034
commit b6d902e425
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 2 deletions

View file

@ -514,6 +514,8 @@
"disableLibraryUpdateOnStartup": "disable checking for new versions on startup",
"discordApplicationId": "{{discord}} application id",
"discordApplicationId_description": "the application id for {{discord}} rich presence (defaults to {{defaultId}})",
"discordPausedStatus": "show rich presence when paused",
"discordPausedStatus_description": "when enabled, status will show when player is paused",
"discordIdleStatus": "show rich presence idle status",
"discordIdleStatus_description": "when enabled, update status while player is idle",
"discordListening": "show status as listening",

View file

@ -24,8 +24,13 @@ export const useDiscordRpc = () => {
current: (number | PlayerStatus | QueueSong | undefined)[],
previous: (number | PlayerStatus | QueueSong | undefined)[],
) => {
// No current song, or we switched to a new track and the player was paused (end of album, etc.)
if (!current[0] || (current[0] && current[2] === 'paused' && current[1] === 0))
if (
!current[0] || // No track
(current[0] &&
current[2] === 'paused' && // Track paused
(discordSettings.showPaused ? current[1] === 0 : true)) || // Beginning of track (only if show paused setting enabled)
(discordSettings.showPaused ? false : current[1] === 0) // Beginning of track (only if show paused setting disabled)
)
return discordRpc?.clearActivity();
// Handle change detection
@ -122,6 +127,7 @@ export const useDiscordRpc = () => {
[
discordSettings.showAsListening,
discordSettings.showServerImage,
discordSettings.showPaused,
generalSettings.lastfmApiKey,
lastUniqueId,
],

View file

@ -74,6 +74,29 @@ export const DiscordSettings = () => {
postProcess: 'sentenceCase',
}),
},
{
control: (
<Switch
checked={settings.showPaused}
onChange={(e) => {
setSettings({
discord: {
...settings,
showPaused: e.currentTarget.checked,
},
});
}}
/>
),
description: t('setting.discordPausedStatus', {
context: 'description',
postProcess: 'sentenceCase',
}),
isHidden: !isElectron(),
title: t('setting.discordPausedStatus', {
postProcess: 'sentenceCase',
}),
},
{
control: (
<Switch

View file

@ -200,6 +200,7 @@ export interface SettingsState {
clientId: string;
enabled: boolean;
showAsListening: boolean;
showPaused: boolean;
showServerImage: boolean;
};
font: {
@ -353,6 +354,7 @@ const initialState: SettingsState = {
clientId: '1165957668758900787',
enabled: false,
showAsListening: false,
showPaused: true,
showServerImage: false,
},
font: {