Fixed play/pause discord rich presence by fixing lastsonginfo tracking (#3551)

This commit is contained in:
Ming Lin
2025-07-02 04:19:28 -04:00
committed by GitHub
parent fec4702ee0
commit bef304865c

View File

@ -275,7 +275,6 @@ export class DiscordService {
} }
// Cache the latest song info // Cache the latest song info
this.lastSongInfo = songInfo;
this.timerManager.clear(TimerKey.ClearActivity); this.timerManager.clear(TimerKey.ClearActivity);
if (!this.rpc || !this.ready) { if (!this.rpc || !this.ready) {
@ -292,7 +291,10 @@ export class DiscordService {
!songChanged && !songChanged &&
isSeek(this.lastSongInfo?.elapsedSeconds ?? 0, elapsedSeconds); isSeek(this.lastSongInfo?.elapsedSeconds ?? 0, elapsedSeconds);
if (songChanged || pauseChanged || seeked) { if (
(songChanged || pauseChanged || seeked) &&
this.lastSongInfo !== undefined
) {
this.timerManager.clear(TimerKey.UpdateTimeout); this.timerManager.clear(TimerKey.UpdateTimeout);
const activityInfo = this.buildActivityInfo(songInfo, this.config); const activityInfo = this.buildActivityInfo(songInfo, this.config);
@ -318,7 +320,6 @@ export class DiscordService {
console.error(LoggerPrefix, 'Failed to set throttled activity:', err), console.error(LoggerPrefix, 'Failed to set throttled activity:', err),
); );
this.lastSongInfo.elapsedSeconds = elapsedSeconds;
this.lastProgressUpdate = now; this.lastProgressUpdate = now;
this.setActivityTimeout(); this.setActivityTimeout();
} else { } else {
@ -348,6 +349,7 @@ export class DiscordService {
remainingThrottle, remainingThrottle,
); );
} }
this.lastSongInfo = { ...songInfo };
} }
/** /**