mirror of
https://github.com/antebudimir/feishin.git
synced 2025-12-31 18:13:31 +00:00
Merge branch 'jeffvli:development' into development
This commit is contained in:
commit
e154810b21
1 changed files with 10 additions and 3 deletions
|
|
@ -18,6 +18,11 @@ import { PlayerStatus } from '/@/shared/types/types';
|
||||||
const discordRpc = isElectron() ? window.api.discordRpc : null;
|
const discordRpc = isElectron() ? window.api.discordRpc : null;
|
||||||
type ActivityState = [QueueSong | undefined, number, PlayerStatus];
|
type ActivityState = [QueueSong | undefined, number, PlayerStatus];
|
||||||
|
|
||||||
|
const MAX_FIELD_LENGTH = 127;
|
||||||
|
|
||||||
|
const truncate = (field: string) =>
|
||||||
|
field.length <= MAX_FIELD_LENGTH ? field : field.substring(0, MAX_FIELD_LENGTH - 1) + '…';
|
||||||
|
|
||||||
export const useDiscordRpc = () => {
|
export const useDiscordRpc = () => {
|
||||||
const discordSettings = useDiscordSettings();
|
const discordSettings = useDiscordSettings();
|
||||||
const generalSettings = useGeneralSettings();
|
const generalSettings = useGeneralSettings();
|
||||||
|
|
@ -66,13 +71,15 @@ export const useDiscordRpc = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const activity: SetActivity = {
|
const activity: SetActivity = {
|
||||||
details: (song?.name && song.name.padEnd(2, ' ')) || 'Idle',
|
details: truncate((song?.name && song.name.padEnd(2, ' ')) || 'Idle'),
|
||||||
instance: false,
|
instance: false,
|
||||||
largeImageKey: undefined,
|
largeImageKey: undefined,
|
||||||
largeImageText: (song?.album && song.album.padEnd(2, ' ')) || 'Unknown album',
|
largeImageText: truncate(
|
||||||
|
(song?.album && song.album.padEnd(2, ' ')) || 'Unknown album',
|
||||||
|
),
|
||||||
smallImageKey: undefined,
|
smallImageKey: undefined,
|
||||||
smallImageText: sentenceCase(current[2]),
|
smallImageText: sentenceCase(current[2]),
|
||||||
state: (artists && artists.padEnd(2, ' ')) || 'Unknown artist',
|
state: truncate((artists && artists.padEnd(2, ' ')) || 'Unknown artist'),
|
||||||
statusDisplayType: statusDisplayMap[discordSettings.displayType],
|
statusDisplayType: statusDisplayMap[discordSettings.displayType],
|
||||||
// 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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue