thanks discord [support changing listen type]

This commit is contained in:
Kendall Garner 2024-08-23 10:34:18 -07:00
parent 284db988c9
commit 906ffee8bc
No known key found for this signature in database
GPG key ID: 18D2767419676C87
4 changed files with 35 additions and 2 deletions

View file

@ -468,6 +468,8 @@
"discordApplicationId_description": "the application id for {{discord}} rich presence (defaults to {{defaultId}})", "discordApplicationId_description": "the application id for {{discord}} rich presence (defaults to {{defaultId}})",
"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_description": "show status as listening instead of playing. note that this currently breaks timer bar",
"discordRichPresence": "{{discord}} rich presence", "discordRichPresence": "{{discord}} rich presence",
"discordRichPresence_description": "enable playback status in {{discord}} rich presence. Image keys are: {{icon}}, {{playing}}, and {{paused}} ", "discordRichPresence_description": "enable playback status in {{discord}} rich presence. Image keys are: {{icon}}, {{playing}}, and {{paused}} ",
"discordUpdateInterval": "{{discord}} rich presence update interval", "discordUpdateInterval": "{{discord}} rich presence update interval",

View file

@ -45,7 +45,7 @@ export const useDiscordRpc = () => {
state: (artists && `By ${artists}`) || 'Unknown artist', state: (artists && `By ${artists}`) || 'Unknown artist',
// I would love to use the actual type as opposed to hardcoding to 2, // I would love to use the actual type as opposed to hardcoding to 2,
// but manually installing the discord-types package appears to break things // but manually installing the discord-types package appears to break things
type: 2, type: discordSettings.showAsListening ? 2 : 0,
}; };
if (currentStatus === PlayerStatus.PLAYING) { if (currentStatus === PlayerStatus.PLAYING) {
@ -73,7 +73,13 @@ export const useDiscordRpc = () => {
} }
discordRpc?.setActivity(activity); discordRpc?.setActivity(activity);
}, [currentSong, currentStatus, discordSettings.enableIdle, discordSettings.showServerImage]); }, [
currentSong,
currentStatus,
discordSettings.enableIdle,
discordSettings.showAsListening,
discordSettings.showServerImage,
]);
useEffect(() => { useEffect(() => {
const initializeDiscordRpc = async () => { const initializeDiscordRpc = async () => {

View file

@ -119,6 +119,29 @@ export const DiscordSettings = () => {
postProcess: 'sentenceCase', postProcess: 'sentenceCase',
}), }),
}, },
{
control: (
<Switch
checked={settings.showAsListening}
onChange={(e) => {
setSettings({
discord: {
...settings,
showAsListening: e.currentTarget.checked,
},
});
}}
/>
),
description: t('setting.discordListening', {
context: 'description',
postProcess: 'sentenceCase',
}),
isHidden: !isElectron(),
title: t('setting.discordListening', {
postProcess: 'sentenceCase',
}),
},
]; ];
return <SettingsSection options={discordOptions} />; return <SettingsSection options={discordOptions} />;

View file

@ -181,6 +181,7 @@ export interface SettingsState {
clientId: string; clientId: string;
enableIdle: boolean; enableIdle: boolean;
enabled: boolean; enabled: boolean;
showAsListening: boolean;
showServerImage: boolean; showServerImage: boolean;
updateInterval: number; updateInterval: number;
}; };
@ -306,6 +307,7 @@ const initialState: SettingsState = {
clientId: '1165957668758900787', clientId: '1165957668758900787',
enableIdle: false, enableIdle: false,
enabled: false, enabled: false,
showAsListening: false,
showServerImage: false, showServerImage: false,
updateInterval: 15, updateInterval: 15,
}, },