From bef304865c295d794a2d10b7cea02671514e2fdc Mon Sep 17 00:00:00 2001 From: Ming Lin <76068638+mingl1@users.noreply.github.com> Date: Wed, 2 Jul 2025 04:19:28 -0400 Subject: [PATCH] Fixed play/pause discord rich presence by fixing lastsonginfo tracking (#3551) --- src/plugins/discord/discord-service.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/discord/discord-service.ts b/src/plugins/discord/discord-service.ts index 9b648a48..4cdc3ab7 100644 --- a/src/plugins/discord/discord-service.ts +++ b/src/plugins/discord/discord-service.ts @@ -275,7 +275,6 @@ export class DiscordService { } // Cache the latest song info - this.lastSongInfo = songInfo; this.timerManager.clear(TimerKey.ClearActivity); if (!this.rpc || !this.ready) { @@ -292,7 +291,10 @@ export class DiscordService { !songChanged && isSeek(this.lastSongInfo?.elapsedSeconds ?? 0, elapsedSeconds); - if (songChanged || pauseChanged || seeked) { + if ( + (songChanged || pauseChanged || seeked) && + this.lastSongInfo !== undefined + ) { this.timerManager.clear(TimerKey.UpdateTimeout); const activityInfo = this.buildActivityInfo(songInfo, this.config); @@ -318,7 +320,6 @@ export class DiscordService { console.error(LoggerPrefix, 'Failed to set throttled activity:', err), ); - this.lastSongInfo.elapsedSeconds = elapsedSeconds; this.lastProgressUpdate = now; this.setActivityTimeout(); } else { @@ -348,6 +349,7 @@ export class DiscordService { remainingThrottle, ); } + this.lastSongInfo = { ...songInfo }; } /**