mirror of
https://github.com/antebudimir/feishin.git
synced 2025-12-31 18:13:31 +00:00
fix: discord presence not clearing after pausing player (#973)
* add show rich presence when paused option
This commit is contained in:
parent
d922d8b034
commit
b6d902e425
4 changed files with 35 additions and 2 deletions
|
|
@ -514,6 +514,8 @@
|
||||||
"disableLibraryUpdateOnStartup": "disable checking for new versions on startup",
|
"disableLibraryUpdateOnStartup": "disable checking for new versions on startup",
|
||||||
"discordApplicationId": "{{discord}} application id",
|
"discordApplicationId": "{{discord}} application id",
|
||||||
"discordApplicationId_description": "the application id for {{discord}} rich presence (defaults to {{defaultId}})",
|
"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": "show rich presence idle status",
|
||||||
"discordIdleStatus_description": "when enabled, update status while player is idle",
|
"discordIdleStatus_description": "when enabled, update status while player is idle",
|
||||||
"discordListening": "show status as listening",
|
"discordListening": "show status as listening",
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,13 @@ export const useDiscordRpc = () => {
|
||||||
current: (number | PlayerStatus | QueueSong | undefined)[],
|
current: (number | PlayerStatus | QueueSong | undefined)[],
|
||||||
previous: (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 (
|
||||||
if (!current[0] || (current[0] && current[2] === 'paused' && current[1] === 0))
|
!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();
|
return discordRpc?.clearActivity();
|
||||||
|
|
||||||
// Handle change detection
|
// Handle change detection
|
||||||
|
|
@ -122,6 +127,7 @@ export const useDiscordRpc = () => {
|
||||||
[
|
[
|
||||||
discordSettings.showAsListening,
|
discordSettings.showAsListening,
|
||||||
discordSettings.showServerImage,
|
discordSettings.showServerImage,
|
||||||
|
discordSettings.showPaused,
|
||||||
generalSettings.lastfmApiKey,
|
generalSettings.lastfmApiKey,
|
||||||
lastUniqueId,
|
lastUniqueId,
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,29 @@ export const DiscordSettings = () => {
|
||||||
postProcess: 'sentenceCase',
|
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: (
|
control: (
|
||||||
<Switch
|
<Switch
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,7 @@ export interface SettingsState {
|
||||||
clientId: string;
|
clientId: string;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
showAsListening: boolean;
|
showAsListening: boolean;
|
||||||
|
showPaused: boolean;
|
||||||
showServerImage: boolean;
|
showServerImage: boolean;
|
||||||
};
|
};
|
||||||
font: {
|
font: {
|
||||||
|
|
@ -353,6 +354,7 @@ const initialState: SettingsState = {
|
||||||
clientId: '1165957668758900787',
|
clientId: '1165957668758900787',
|
||||||
enabled: false,
|
enabled: false,
|
||||||
showAsListening: false,
|
showAsListening: false,
|
||||||
|
showPaused: true,
|
||||||
showServerImage: false,
|
showServerImage: false,
|
||||||
},
|
},
|
||||||
font: {
|
font: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue