Removing playlists

I am running volumio 3.067pi on rpi3b. I can not remove songs from playlist or can not remove playlist. This is also an issue on volumio 2.

I can do both, but this seems at odds with other people’s observations Playlist problems . This is on both Volumio 2 & 3. I guess it needs some systematic investigation.

I looked in the livelog there are no errors, but playlist is not deleted. Maybe it has something to do with my volumio?:

info: CURURI: playlists
info: Listing playlists
info: CoreCommandRouter::executeOnPlugin: mpd , handleBrowseUri
info: CURURI: playlists/Bandcamp Artists
info: Removing uri bandcamp/search@query=riversea@combinedSearch=1/artist@artistUrl=https%3A%2F%2Friversea.bandcamp.com/album@albumUrl=https%3A%2F%2Friversea.bandcamp.com%2Falbum%2Fthe-tide-2 to playlist Bandcamp Artists
info: Saving Cloud item Bandcamp Artists
info: CoreCommandRouter::executeOnPlugin: my_volumio , saveCloudItem
info: CoreCommandRouter::executeOnPlugin: mpd , handleBrowseUri

When you remove an item from the playlist, Volumio UI emits the removeFromPlaylist command:

// https://github.com/volumio/Volumio2-UI/blob/master/src/app/services/playlist.service.js

this.socketService.emit('removeFromPlaylist', {
      name: playlist,
      uri: item.uri,
      service: (item.service || null)
    });

Volumio backend receives this command and then does the following:

// https://github.com/volumio/Volumio2/blob/master/app/plugins/user_interface/websocket/index.js

connWebSocket.on('removeFromPlaylist', function (data) {
      ...
      var returnedData = self.commandRouter.playListManager.removeFromPlaylist(data.name, 'mpd', data.uri);
      ...
}

As you can see, the backend completely ignores the service property of data passed by Volumio UI and uses ‘mpd’ no matter what. Then, in playlistManager, the item is removed through the following:

// https://github.com/volumio/Volumio2/blob/master/app/playlistManager.js
...
for (var i = 0; i < data.length; i++) {
  if (data[i].service == service && data[i].uri == uri) {
    removedItem = data.splice(i, 1)[0];
    break;
  }
}
...

The code iterates through the items of a playlist, compares the service and uri properties of each, and removes the one that matches. Since ‘mpd’ is specified as the service every time, removing items that correspond to another service will fail (you will still get a success message because the code doesn’t care if the playlist item is not found).

So that’s the reason. What I don’t understand is, why go through this time-consuming ‘compare → remove’ process? Volumio UI should know the index (position) of the item in the list and can pass it to removePlaylist, which can then remove the item directly at the specified index. Or am I missing something?