Skip to content

Commit

Permalink
DiscordRPC: Listen to time update instead of seek
Browse files Browse the repository at this point in the history
- Time updates don't trigger updates. Instead, they just update the time variable, which is used by other updates.
- `SET_PLAYBACK_STATE` fires when seeking anyway, so RPC is still updated.
- Removed `update` call from `MEDIA_PRODUCT_TRANSITION` for the same reasons.
  • Loading branch information
n1ckoates committed Sep 16, 2024
1 parent 8076b58 commit cbd6e29
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions plugins/DiscordRPC/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,13 @@ const unloadTransition = intercept(
([media]) => {
const mediaProduct = media.mediaProduct as { productId: string };
MediaItemCache.ensure(mediaProduct.productId)
.then((track) => {
if (track) update({ track, time: 0 });
})
.then((newTrack) => (track = newTrack))
.catch(trace.err.withContext("Failed to fetch media item"));
}
);

const unloadSeek = intercept("playbackControls/SEEK", ([time]) => {
if (typeof time === "number") update({ time });
const unloadTime = intercept("playbackControls/TIME_UPDATE", ([newTime]) => {
time = newTime;
});

const unloadPlay = intercept(
Expand All @@ -121,7 +119,7 @@ update({

export const onUnload = () => {
unloadTransition();
unloadSeek();
unloadTime();
unloadPlay();
unloadPause();
window.electron.ipcRenderer
Expand Down

0 comments on commit cbd6e29

Please sign in to comment.