Skip to content

Commit

Permalink
Use id
Browse files Browse the repository at this point in the history
  • Loading branch information
captbaritone committed Aug 25, 2024
1 parent e127d42 commit 525e17e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/webamp/js/webampLazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 525e17e

Please sign in to comment.