mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-27 12:03:52 +00:00
Use id
This commit is contained in:
parent
e127d42fb6
commit
525e17ed2c
1 changed files with 5 additions and 4 deletions
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue