Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"@tanstack/react-query-devtools": "^4.32.1",
"@tanstack/react-query-persist-client": "^4.32.1",
"@ts-rest/core": "^3.23.0",
"@xhayper/discord-rpc": "^1.0.24",
"@xhayper/discord-rpc": "^1.3.0",
"audiomotion-analyzer": "^4.5.0",
"auto-text-size": "^0.2.3",
"axios": "^1.6.0",
Expand Down
57 changes: 30 additions & 27 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,10 @@
"discordServeImage_description": "share cover art for {{discord}} rich presence from server itself, only available for jellyfin and navidrome",
"discordUpdateInterval": "{{discord}} rich presence update interval",
"discordUpdateInterval_description": "the time in seconds between each update (minimum 15 seconds)",
"discordDisplayType": "{{discord}} presence display type",
"discordDisplayType_description": "changes what you are listening to in your status",
"discordDisplayType_songname": "song name",
"discordDisplayType_artistname": "artist name(s)",
"doubleClickBehavior": "queue all searched tracks when double clicking",
"doubleClickBehavior_description": "if true, all matching tracks in a track search will be queued. otherwise, only the clicked one will be queued",
"enableRemote": "enable remote control server",
Expand Down
13 changes: 11 additions & 2 deletions src/renderer/features/discord-rpc/use-discord-rpc.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { SetActivity } from '@xhayper/discord-rpc';
import { SetActivity, StatusDisplayType } from '@xhayper/discord-rpc';
import isElectron from 'is-electron';
import { useCallback, useEffect, useState } from 'react';

import { controller } from '/@/renderer/api/controller';
import {
DiscordDisplayType,
getServerById,
useDiscordSetttings,
useGeneralSettings,
Expand Down Expand Up @@ -54,14 +55,21 @@ export const useDiscordRpc = () => {

const artists = song?.artists.map((artist) => artist.name).join(', ');

const statusDisplayMap = {
[DiscordDisplayType.ARTIST_NAME]: StatusDisplayType.STATE,
[DiscordDisplayType.FEISHIN]: StatusDisplayType.NAME,
[DiscordDisplayType.SONG_NAME]: StatusDisplayType.DETAILS,
};

const activity: SetActivity = {
details: song?.name.padEnd(2, ' ') || 'Idle',
instance: false,
largeImageKey: undefined,
largeImageText: song?.album || 'Unknown album',
smallImageKey: undefined,
smallImageText: current[2] as string,
state: (artists && `By ${artists}`) || 'Unknown artist',
state: artists || 'Unknown artist',
statusDisplayType: statusDisplayMap[discordSettings.displayType],
// 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
type: discordSettings.showAsListening ? 2 : 0,
Expand Down Expand Up @@ -134,6 +142,7 @@ export const useDiscordRpc = () => {
discordSettings.showPaused,
generalSettings.lastfmApiKey,
discordSettings.clientId,
discordSettings.displayType,
lastUniqueId,
],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import {
SettingsSection,
} from '/@/renderer/features/settings/components/settings-section';
import {
DiscordDisplayType,
useDiscordSetttings,
useGeneralSettings,
useSettingsStoreActions,
} from '/@/renderer/store';
import { Select } from '/@/shared/components/select/select';
import { Switch } from '/@/shared/components/switch/switch';
import { TextInput } from '/@/shared/components/text-input/text-input';

Expand Down Expand Up @@ -120,6 +122,50 @@ export const DiscordSettings = () => {
postProcess: 'sentenceCase',
}),
},
{
control: (
<Select
aria-label={t('setting.discordDisplayType')}
clearable={false}
data={[
{ label: 'Feishin', value: DiscordDisplayType.FEISHIN },
{
label: t('setting.discordDisplayType', {
context: 'songname',
postProcess: 'sentenceCase',
}),
value: DiscordDisplayType.SONG_NAME,
},
{
label: t('setting.discordDisplayType_artistname', {
context: 'artistname',
postProcess: 'sentenceCase',
}),
value: DiscordDisplayType.ARTIST_NAME,
},
]}
defaultValue={settings.displayType}
onChange={(e) => {
if (!e) return;
setSettings({
discord: {
...settings,
displayType: e as DiscordDisplayType,
},
});
}}
/>
),
description: t('setting.discordDisplayType', {
context: 'description',
postProcess: 'sentenceCase',
}),
isHidden: !isElectron(),
title: t('setting.discordDisplayType', {
discord: 'Discord',
postProcess: 'sentenceCase',
}),
},
{
control: (
<Switch
Expand Down
8 changes: 8 additions & 0 deletions src/renderer/store/settings.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ export enum BindingActions {
ZOOM_OUT = 'zoomOut',
}

export enum DiscordDisplayType {
ARTIST_NAME = 'artist',
FEISHIN = 'feishin',
SONG_NAME = 'song',
}

export enum GenreTarget {
ALBUM = 'album',
TRACK = 'track',
Expand Down Expand Up @@ -198,6 +204,7 @@ export interface SettingsState {
};
discord: {
clientId: string;
displayType: DiscordDisplayType;
enabled: boolean;
showAsListening: boolean;
showPaused: boolean;
Expand Down Expand Up @@ -353,6 +360,7 @@ const initialState: SettingsState = {
},
discord: {
clientId: '1165957668758900787',
displayType: DiscordDisplayType.FEISHIN,
enabled: false,
showAsListening: false,
showPaused: true,
Expand Down
Loading