From 525e17ed2cb5235c2f156fa5bcfd0d1d1898d1a6 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Sun, 25 Aug 2024 11:30:48 -0700 Subject: [PATCH] Use id --- packages/webamp/js/webampLazy.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/webamp/js/webampLazy.tsx b/packages/webamp/js/webampLazy.tsx index a4dffd412..e96617e31 100644 --- a/packages/webamp/js/webampLazy.tsx +++ b/packages/webamp/js/webampLazy.tsx @@ -367,16 +367,17 @@ class Webamp { * you want to stop listening to these events. */ onCurrentTrackDidChange( - cb: (currentTrack: PlaylistTrack, trackIndex: number) => void + cb: (currentTrack: PlaylistTrack | null, trackIndex: number) => void ): () => void { - let previousTrack: PlaylistTrack | null = null; + let previousTrackId: number | null = null; return this.store.subscribe(() => { const state = this.store.getState(); const currentTrack = Selectors.getCurrentTrack(state); - if (currentTrack == null || currentTrack === previousTrack) { + const currentTrackId = currentTrack?.id || null; + if (currentTrackId === previousTrackId) { return; } - previousTrack = currentTrack; + previousTrackId = currentTrackId; const trackIndex = Selectors.getCurrentTrackIndex(state); cb(currentTrack, trackIndex); });