Skip to content

Commit

Permalink
fix correcting playlist when removing song
Browse files Browse the repository at this point in the history
  • Loading branch information
stCarolas committed Mar 9, 2024
1 parent 96bcab2 commit c873b21
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/logic/playlist/Playlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,18 @@ class Playlist {
}

removeSong(index: number) {
if (index < 0 || index > this._songs.length) {
if (index < 0 || index >= this._songs.length) {
return;
}
const originId = this._songs[index].originId;
if (originId) {
markListened(originId);
}
this._songs.splice(index, 1);
if (this._songs.length == 0) {
if (
this._songs.length == 0 ||
(this._index && this._index >= this._songs.length)
) {
this._index = null;
}
this.triggerListeners();
Expand Down

0 comments on commit c873b21

Please sign in to comment.