hrkfdn / ncspot

Cross-platform ncurses Spotify client written in Rust, inspired by ncmpc and the likes.
BSD 2-Clause "Simplified" License
5.1k stars 213 forks source link

Track deleting not working reliably #1152

Open Bettehem opened 1 year ago

Bettehem commented 1 year ago

The d button should delete the selected track from a playlist, which it does, sometimes.

A user had a question regarding track deletion in https://github.com/hrkfdn/ncspot/discussions/1122 but it seems they are already trying to delete tracks the correct way, so I thought I'd open an issue for this.

I have also been experiencing the same problem. d just doesn't always seem to work.

I may have found a way to reproduce the issue but I'm not sure if it works like this every time.

Just now I tested again by adding a couple tracks to a playlist, then I navigated to that playlist and tried pressing d on both of the tracks but nothing happened for either of them. Then I tried refreshing the library with Shift+U, no effect and pressing d after refreshing also changes nothing. Next I tried to restart ncspot, navigate to the playlist, then pressed d on those tracks I previously added, and now they got deleted immediately upon pressing the key.

Here's the interesting part and may hint to the cause of the problem: If I now try to add the same track(s) again, then navigate to the playlist and press d on the track I just added, nothing happens. Only after restarting ncspot it seems like I'm able to delete the tracks I just added

ThomasFrans commented 1 year ago

I've been trying to solve this but it's more complicated than I thought. I first thought it would be a problem with the synchronization between the playlist in the view and the one in the library, but that doesn't seem to be it. The playlist's snapshot_id seems to not update when modifying the playlist which is checked by the Spotify API (https://developer.spotify.com/documentation/web-api/reference/remove-tracks-playlist). I could solve this probably but don't have time right now. Thought I'd leave this here if someone else wants to solve this in the meantime, otherwise I'll try further a bit later :slightly_smiling_face:

The reason it works when removing tracks without updating the snapshot_id seems to be because you only need the snapshot_id of a playlist that is similar enough to the one you're operating on.

Bettehem commented 1 year ago

Interesting. I'm currently busy with other projects so I don't have much time to look into this but I can also try to help if you haven't been able to solve it by then

cyqsimon commented 1 year ago

This issue caught my attention after I noticed that the behaviour of save (s) and delete (d) commands in documentation do not seem to match their actual behaviour.

Save

Delete

This is probably a simple case of outdated documentation, but it also suggests that those commands were changed and/or expanded upon after their initial implementation. It's possible that there were some invariant assumption that was made during initial implementation, but were then forgotten about and then violated accidentally later on. Maybe this is a line of thought worth investigating.