Merge branch 'jeffvli:development' into development

This commit is contained in:
Ante 2025-11-17 09:51:22 +02:00 committed by GitHub
commit e154810b21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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