mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-15 12:21:47 +00:00
Fixed play/pause discord rich presence by fixing lastsonginfo tracking (#3551)
This commit is contained in:
@ -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 };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user